Dubya008 Posted March 17, 2011 Share Posted March 17, 2011 I'm looking for a method that will return the date for the next 2 weeks in php. I can pull the date but I'm not sure about adding to the date. Can anyone point me in the correct direction? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 17, 2011 Share Posted March 17, 2011 Look at the strtotime() function. Ken Quote Link to comment Share on other sites More sharing options...
aabid Posted March 17, 2011 Share Posted March 17, 2011 <?php for($i=1; $i<15; $i++) { $today = strtotime("+$i day"); $day = getdate($today); echo "$day[mday]<br>"; } ?> This will return the dates of next 14 days......I am sure there might be the better way to display the dates but this will work also. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 17, 2011 Share Posted March 17, 2011 Another way: <?php $two = strtotime('+2 weeks'); $date = time(); while ($date <= $two) { echo date('l, F j, Y',$date) . "<br>"; $date += 86400; //86400 seconds in a day } ?> Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.