954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

tomorrow date??? .

I am trying to assign tomorrow date to a variable in my program call $tomorrow, but i just cant seem to work out how to do it. Have done today's one by doing

$date = date('Y-m-d');

after reseraching I thought it will make sense to do this

$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
but this produced a long number (1141689600). making no sense.

I want the output to be as the same format as the date function used above.

Please please please please can someone help me. Thanks in advance

nike123
Newbie Poster
20 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

[PHP]
$tomorrow = date('Y-m-d',mktime(0,0,0,date('m'), date('d')+1, date('Y')));
[/PHP]

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

Troy's code will work just fine, here's another way of doing it:
[php]$tomorrow = date('Y-m-d',mktime()+86400);[/php]

paradox814
Posting Whiz
351 posts since Oct 2004
Reputation Points: 13
Solved Threads: 4
 

;) Troy's code will work just fine, here's another way of doing it:
[php]$tomorrow = date('Y-m-d',mktime()+86400);[/php]

Hi,

I think is better to use time() instead of mktime() in this case ;)

And a little explanation:

date() function get's two arguments. first one is date format, second one is function time() which get the current time in UNIX format.
We can manipulate time() function with - or + time.
so 86400 is the sum for the seconds in 24hours.
24*60*60 (24 hours * 60 mins * 60 sec).
Well date function will convert UNIX time time stamp to your date format. That's is...

excuse my english it's not my native language and i hope this will help you to understand how the things work out

ludesign
Newbie Poster
9 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

Thanks alot guys. Those codes works.

nike123
Newbie Poster
20 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

hi,


try this

TOMORROW=`expr \`date +%s\` + 86400`
date -r $TOMORROW

rahulgs
Newbie Poster
1 post since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You