ajmcello Posted December 6, 2006 Share Posted December 6, 2006 For example, if $date1 is 11/25/06 and $date2 is 12/04/06, how would I go about finding all the dates inbetween (11/25/06, 11/26/06, 11/27/06 etc...) ?Thanks. :) Link to comment https://forums.phpfreaks.com/topic/29719-how-do-i-calculate-the-dates-between-two-dates/ Share on other sites More sharing options...
kenrbnsn Posted December 6, 2006 Share Posted December 6, 2006 You need to convert the dates to unix timestamps and use those in a for loop:[code]<?php$date1 = '11/25/06';$date2 = '12/04/06';$start = strtotime($date1);$end = strtotime($date2);while ($start <= $end) { echo date('m/d/y',$start),'<br>'; $start += 86400; // 86400 seconds in a day}?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/29719-how-do-i-calculate-the-dates-between-two-dates/#findComment-136429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.