Hey, i'm new to PHP and i'm having trouble with the date() function. I need to get todays date and the following 5 days after. it needs to be in the following format "mm/dd/yyyy". Can anyone help me out? thanks
$unix_stamp = strtotime("now"); //today $unix_stamp = strtotime("+1 day"); //tomorrow echo date("m/d/Y", $unix_stamp); PHP:
http://www.php.net/date <?php //get timestamp for past/future date I want $pf_time = strtotime("+5 days"); //format the date using the timestamp generated $pf_date = date("m/d/Y", $pf_time); echo $pf_date ; ?> Code (markup): this prints C:\Documents and Settings\User\regexp>php -f date.php 07/31/2006 C:\Documents and Settings\User\regexp> Code (markup):
This is another solution, is that clearer? In this ways, we can get exactly next/previous time (in seconds) <? $now=time(); // Current timestamp $nextFiveDay=$now+5*24*3600; // exactly next 5 day echo "Next five days: ".date("m/d/Y",$nextFiveDay); ?> PHP: