Re: Problem with date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adding the number of seconds in a day could fall in the same day due
to daylight saving time, a more reliable way of adding one day (or a
given number of days) is this:

$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));

Then use date() with $tomorrow to format it.

(Taken from example #3 here:
http://www.php.net/manual/en/function.date.php, see the Note below the
example in that page).

Hope that helps.

Regards,
Jonathan


2009/9/15 Korgan <josberger@xxxxxxxxx>:
> Hi,
>
>  I have a problem with date function.
>
> $gen_pos = mktime(0,0,1,10,25,2009);
> $d1 = date("Y-m-d", $gen_pos);                // 2009-10-25
> $d2 = date("Y-m-d", $gen_pos + (1*24*60*60)); // 2009-10-25
> $d3 = date("Y-m-d", $gen_pos + (2*24*60*60)); // 2009-10-26
> $d4 = date("Y-m-d", $gen_pos + (3*24*60*60)); // 2009-10-27
> $d5 = date("Y-m-d", $gen_pos + (4*24*60*60));
> $d6 = date("Y-m-d", $gen_pos + (5*24*60*60));
> $d7 = date("Y-m-d", $gen_pos + (6*24*60*60));
> $d8 = date("Y-m-d", $gen_pos + (7*24*60*60));
>
> line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 ,
> 2009-10-26 ? :)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux