English 中文(简体)
PHP——2个日期之间的差数(90000而不是86400)
原标题:PHP - strange difference in seconds between 2 dates (90000 instead of 86400)

如今,与公共卫生和社会福利部有一些奇怪的行为:

$ds = array( 2011-10-28 ,  2011-10-29 ,  2011-10-30 ,  2011-10-31 , 2011-11-01 );
for($i=0; $i<count($ds); $i++) {
  print_r($ds[$i].   .strtotime($ds[$i])."
");
  if ($i < count($ds)-1) {
    print_r(abs(strtotime($ds[$i+1]) - strtotime($ds[$i]))."
");
  }
}

产出:

2011-10-28 1319756400
86400
2011-10-29 1319842800
86400
2011-10-30 1319929200
90000
2011-10-31 1320019200
86400
2011-11-01 1320105600

Can anyone explain the anomalous 90 thousand between 30th and 31st?

最佳回答

900秒钟为25小时,每天25小时只能指一件事。 这些衣物被击退到日光节省时间。

当然,在联合王国(我不知道别处),星期天上午发生,造成第30天为25小时。

问题回答

由于日光储蓄时间的改变,这一时间似乎增加了一个小时:

90000 = 25 * 60 * 60

For proper conversion you should add to the date the string " +00" (UTC time zone).
For example strtotime("2011-10-30 +00");





相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签