You are here: Re: how do you get a list of all dates between two dates more than a day apart? « PHP Programming Language « IT news, forums, messages
Re: how do you get a list of all dates between two dates more than a day apart?

Posted by Pedro Graca on 01/21/06 02:17

Notgiven wrote:
> Say you have two dates, 2005-01-01 and 2005-01-24. I want to get a list or
> array or all the date between and including those two dates.
>
> I want to include this list in a query so I need it in a format like:
> '2005-01-01', '2005-01-02',...

<?php
$d0 = gmmktime(0, 0, 0, 1, 1, 2005);
$d1 = gmmktime(0, 0, 0, 1, 24, 2005);
$day = 24*60*60;

$date_list = array();
for ($date_index = $d0; $date_index <= $d1; $date_index += $day) {
$date_list[] = gmdate('Y-m-d', $date_index);
}

print_r($date_list);
?>

--
If you're posting through Google read <http://cfaj.freeshell.org/google>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация