Timestamp için gün ekleme

0 Cevap

Bir başlangıç ​​tarihini veren, 5 farklı tarih tam olarak bir hafta, her biri ayrı almak için yedi gün dört kez ekliyorum.

//$date = '28-10-2010';
$timestamp = mktime( 0, 0, 0, 10, 01, 2010 );
echo "Date=".date( 'd-m-Y', $timestamp )."<br>";

$timestamp += (60*60*24*7);
echo "Date=".date( 'd-m-Y', $timestamp )."<br>";

$timestamp += (60*60*24*7);
echo "Date=".date( 'd-m-Y', $timestamp )."<br>";

$timestamp += (60*60*24*7);
echo "Date=".date( 'd-m-Y', $timestamp )."<br>";

$timestamp += (60*60*24*7);
echo "Date=".date( 'd-m-Y', $timestamp )."<br>";

Kod bu çıkışlar:

Date=01-10-2010 Friday
Date=08-10-2010 Friday
Date=15-10-2010 Friday
Date=22-10-2010 Friday
Date=29-10-2010 Friday

Which as long as I know it's correct. But, see what happens when going through the 2010-10-31 and 2010-11-01

$timestamp = mktime( 0, 0, 0, 10, 28, 2010 ); [...]

İlginçtir bu çıkışları:

Date=28-10-2010 Thursday
Date=03-11-2010 Wednesday
Date=10-11-2010 Wednesday
Date=17-11-2010 Wednesday
Date=24-11-2010 Wednesday

What's happening? Second date should be 04-11-2010! Also, I saw that this "fail" happens every ten years! Is this something related with the daylight savings time? If so, how do I solve it? Is there anything that i am overlooking?

Edit: Tamam, ben sadece ne olacağını görmek için, zaman outputed ve bu şimdi ne var:

Date=28-10-2010 Thursday :: 00:00:00
Date=03-11-2010 Wednesday :: 23:00:00
Date=10-11-2010 Wednesday :: 23:00:00
Date=17-11-2010 Wednesday :: 23:00:00
Date=24-11-2010 Wednesday :: 23:00:00

Zamanla ilgili bir şey gibi görünüyor, bir şey 2010/11/31 olur ...

0 Cevap