RE: [PHP] Date addition problem
| From: | Weber Sites LTD | Date: | Wed, 29 Mar 2006 18:21:35 +0000 |
| Subject: | RE: [PHP] Date addition problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232862@lists.php.net to get a copy of this message | ||
Date of today +1 .. +x days
http://www.weberdev.com/get_example-292.html
Sincerely
berber
Visit the Weber Sites Today,
To see where PHP might take you tomorrow.
SEO Data Monitor http://seo.weberdev.com
-----Original Message-----
From: Adrian Bruce [mailto:abruce@stvincent.ac.uk]
Sent: Wednesday, March 29, 2006 2:52 PM
To: php-general@lists.php.net
Subject: [PHP] Date addition problem
Hi
I am having an unusual problem when trying to calculate dates in advance
from a start date. the code below shows a loop where by on each run an
increasing number of weeks is added to the start date, this works as
expected up untill the 8th time where for some reason it produces
01-11-05 instead of 02-11-05. I am at a loss as to why this would happen
when it works perfectly for all the other dates. where am i going wrong?
[snip]
<?php
echo"<h1> date test</h1>";
$start = "05-09-07";
$start = explode('-',$start);
$startmk = mktime(0,0,0,$start[1],$start[2],$start[0]);
$startdate = date('d-m-y',$startmk);
for($i=0;$i<10;$i++){
$nextdate = date('d-m-y',$startmk + ($i*604800));
echo"<h1>$i: $startdate -- -- --$nextdate</h1>"; }
?>
OUTPUT:
0: 07-09-05 -- -- --07-09-05
1: 07-09-05 -- -- --14-09-05
2: 07-09-05 -- -- --21-09-05
3: 07-09-05 -- -- --28-09-05
4: 07-09-05 -- -- --05-10-05
5: 07-09-05 -- -- --12-10-05
6: 07-09-05 -- -- --19-10-05
7: 07-09-05 -- -- --26-10-05
8: 07-09-05 -- -- --01-11-05
9: 07-09-05 -- -- --08-11-05
[/snip]
Thanks a lot
Ade
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php