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

Recommended Answers

All 5 Replies

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

Troy's code will work just fine, here's another way of doing it:

$tomorrow = date('Y-m-d',mktime()+86400);

;)

Troy's code will work just fine, here's another way of doing it:

$tomorrow = date('Y-m-d',mktime()+86400);

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

Thanks alot guys. Those codes works.

hi,


try this

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.