list all dates - date range

11-12-04, 04:39 AM
|
|
Newbie Coder
|
|
Join Date: Nov 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
list all dates - date range
G'day
If someone could please help me...
I'm trying to find out a way where i can list all dates within a date range.
Like this:::
2004-10-02 to 2004-10-05 would display:
2004-10-02
2004-10-03
2004-10-04
2004-10-05
Any ideas?
By the way, the dates are in a db if it helps/matters...
|

11-12-04, 06:16 AM
|
|
Junior Code Guru
|
|
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
something like
PHP Code:
function ListDays ($startdate, $enddate) { $tmp[0] = split('-', $startdate); $tmp[1] = split('-', $enddate); $date = mktime(0, 0, 0, $tmp[0][1], $tmp[0][2], $tmp[0][0]); $end = mktime(0, 0, 0, $tmp[1][1], $tmp[1][2], $tmp[1][0]); while ($date <= $end) { echo date('Y-m-d').'<br />'; $date += (24*60*60); } return true; }
its untested and might not be as fast as it could be but should list the dates
hope it helps
Wille
|

11-12-04, 07:25 AM
|
|
Newbie Coder
|
|
Join Date: Nov 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Big thanks
Thanks, it worked with a small mod! Thanks a lot would never have figured it out myself!
Here is the mod if anyone is looking for it
<?php
function ListDays ($startdate, $enddate) {
$tmp[0] = split('-',$startdate);
$tmp[1] = split('-',$enddate);
$date = mktime(0,0,0,$tmp[0][1], $tmp[0][2], $tmp[0][0]);
$end = mktime(0,0, 0, $tmp[1][1], $tmp[1][2], $tmp[1][0]);
while ($date <= $end) {
echo strftime("%Y-%m-%d",$date);
echo '<br />';
$date += (24*60*60);
}
return true;
}
?>
|

11-12-04, 07:53 AM
|
|
Junior Code Guru
|
|
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i did it again.. didnt think it to the end..
PHP Code:
<? function ListDays ($startdate, $enddate) { $tmp[0] = split('-',$startdate); $tmp[1] = split('-',$enddate); $date = mktime(0, 0, 0, $tmp[0][1], $tmp[0][2], $tmp[0][0]); $end = mktime(0, 0, 0, $tmp[1][1], $tmp[1][2], $tmp[1][0]); while ($date <= $end) { echo date('Y-m-d', $date).'<br />'; # never used the $date variable witch resulted it to output today $date += (24*60*60); } return true; } ?>
glad you got it working tho
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|