|
Posted by Carl Vondrick on 01/29/07 06:14
Should do it. Uses unix time stamps.
<?php
function generate_dates($start, $end)
{
$start = strtotime($start);
$end = strtotime($end);
$oneday = 86400;
$return = array();
for ($current = $start; $current <= $end; $current+=$oneday)
{
$return[] = $current;
}
return $return;
}
print '<pre>'; print_r(generate_dates('jan 1, 2005','today'));
?>
> Hi,
>
> Using PHP 4.4.4, I want to generate an array that contains strings
> representing days from Jan. 1, 2005 to whatever the current day is.
> So the array would contain the first values
>
> '2005-01-01', '2005-01-02', '2005-01-03'
>
> and end with the values
>
> '2007-01-27', '2007-01-28'
>
> In case you're interested, I will then take this array and populate a
> MySQL table.
>
> Thanks for any advice, - Dave
--
Carl Vondrick
www.CarlSoft.net
Navigation:
[Reply to this message]
|