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? Link to comment https://forums.phpfreaks.com/topic/230889-getting-the-next-2-weeks-in-php/ Share on other sites More sharing options...
kenrbnsn Posted March 17, 2011 Share Posted March 17, 2011 Look at the strtotime() function. Ken Link to comment https://forums.phpfreaks.com/topic/230889-getting-the-next-2-weeks-in-php/#findComment-1188557 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. Link to comment https://forums.phpfreaks.com/topic/230889-getting-the-next-2-weeks-in-php/#findComment-1188564 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 Link to comment https://forums.phpfreaks.com/topic/230889-getting-the-next-2-weeks-in-php/#findComment-1188565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.