gerkintrigg Posted March 21, 2007 Share Posted March 21, 2007 I've been pulling my hair out for the last few days trying to get this to work, but I've finally given up and hope that you guys and girls can help me. $limiter=date(Y)+1; $limiter=date('m/d').$limiter; $x_days='7'; while (strtotime($start_date)<=strtotime($limiter)){ echo date('d/m/Y',$start_date).'<BR>'; echo date('d/m/Y',strtotime($limiter)).'<BR><br>'; //echo date('l F d Y',$start_date).' To '; //echo date('l F d Y', strtotime('+'.$x_days.' days',$start_date)).'<BR>'; $start_date=strtotime('+'.$x_days.' days', $start_date); } It keeps looping through until it gets to 1970!(?) Any suggestions? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/43668-solved-time-and-date-comparisons/ Share on other sites More sharing options...
kenrbnsn Posted March 21, 2007 Share Posted March 21, 2007 You should be doing all your work with the UNIX timestamp, you're using both the UNIX timestamp and the ASCII date string which is where the "1970" value is coming from. Try this: <?php $start_date = time(); $limiter=date(Y)+1; $limiter=strtotime(date('m/d/').$limiter); $x_days='7'; while ($start_date<=$limiter){ echo date('d/m/Y',$start_date).'<BR>'; echo date('d/m/Y',$limiter).'<BR><br>'; //echo date('l F d Y',$start_date).' To '; //echo date('l F d Y', strtotime('+'.$x_days.' days',$start_date)).'<BR>'; $start_date=strtotime('+'.$x_days.' days', $start_date); } ?> Ken Link to comment https://forums.phpfreaks.com/topic/43668-solved-time-and-date-comparisons/#findComment-211975 Share on other sites More sharing options...
gerkintrigg Posted March 21, 2007 Author Share Posted March 21, 2007 ah fantastic! Thanks very much for that! Link to comment https://forums.phpfreaks.com/topic/43668-solved-time-and-date-comparisons/#findComment-211983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.