Add Date,day sun mon

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Scoobs
Forum Newbie
Posts: 8
Joined: Wed Sep 08, 2010 1:21 pm

Add Date,day sun mon

Post by Scoobs »

Im trying to add another day,This is what I have
if (date("D") == "Mon") This works fine
I need it to also have Tue in it,
if (date("D") == "Mon","Tue") will not work
if (date("D") == 'Mon' OR date = 'Tue') will not work
Thanks for any and all help :)
mikecampbell
Forum Commoner
Posts: 38
Joined: Tue Oct 12, 2010 7:26 pm

Re: Add Date,day sun mon

Post by mikecampbell »

I've got no idea what exactly you're trying to do, but

Code: Select all

if (date("D") == "Mon","Tue")
is not valid PHP syntax. This might be what you want

Code: Select all

if ((date("D") == "Mon") || (date("D") == "Tue"))
If you want to add one day to a date, you can use the date_add function ( http://www.php.net/manual/en/datetime.add.php ) or something like

Code: Select all

date("D", time()+86400);
Scoobs
Forum Newbie
Posts: 8
Joined: Wed Sep 08, 2010 1:21 pm

Re: Add Date,day sun mon

Post by Scoobs »

That was great help This actually worked in a few lines
if ((date("D") == "Mon") || (date("D") == "Tue"))
Thanks !!!!!
In other lines I had to just change the || to &&
if ((date("D") == "Mon") && (date("D") == "Tue"))
And add the rest of the code ,
Thanks your 1 reply and it worked, Im impressed , and again thanks,
I just taught myself last year on this to create a game, Rather fun to learn something new

Hope this helps others . Big Thanks to mikecampbell
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Add Date,day sun mon

Post by McInfo »

Scoobs wrote:In other lines I had to just change the || to &&

Code: Select all

if ((date("D") == "Mon") && (date("D") == "Tue"))
When will it ever be Monday and Tuesday at the same time in one place? That condition will never be true.
Post Reply