Home  >  Article  >  Backend Development  >  指定时间是否为夏令制

指定时间是否为夏令制

WBOY
WBOYOriginal
2016-06-23 14:24:531369browse

如何判断指定时间来获取是否采用美国夏令制

我知道可以写一个函数来判断当前是否为美国夏令制...

但是找咯一下没有说指定时间来判断....


//夏令制判断
function is_dst(){
  $timezone=date('e');  //获取当前使用的时区
  date_default_timezone_set('US/Pacific-New'); //强制设置时区
  $dst=date('I');  //判断是否夏令时
  date_default_timezone_set($timezone);  //还原时区
  return $dst;  //返回结果

}


回复讨论(解决方案)

date 的第二个参数不就是用于指定时间的吗

第二个参数貌似不行...

$lastUpdateint= 13819522810;

echo date("I",lastUpdateint);
返回的结果为0....

不知道我对夏令时的理解是否有误  那只是一种人为的设定吧

时间戳是1970年到某一时间点的秒数   这个某一时间点,在不同的国家 不同的时制下可以有不同的当地时间

但是你怎么有可能得出这个时间秒数是从夏令时的美国得到的呢?


如果不是我理解错误 就是你这个需求是不可能实现的.

 * USA DST
 * From 2:00 AM at the second week of March To  2:00 AM at the first weeek of November
这是美国的夏令时起止时间~

至于所在区域是否使用夏令时需要自己维护一个列表~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn