duancong2965 2014-06-13 21:14
浏览 52
已采纳

PHP IntlDateFormatter ::解析输出时区

I have the following PHP code:

$date = 'janvier 1, 2014 à 5:00PM';
$formatter = new IntlDateFormatter('fr_CA', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Toronto', IntlDateFormatter::GREGORIAN, 'MMMM d, yyyy 'à' h:mma');
$date = $formatter->parse($date);
var_dump($date);

The output is:

int(1388613600)

This appears to be a UNIX timestamp, which is always UTC, Right? So it's automatically being converted from America/Toronto?

Just confirming that I have this correct. I don't have a lot of experience with PHP and time zones, so I appreciate any help.

  • 写回答

2条回答 默认 最新

  • douyinglan2599 2014-06-13 21:37
    关注

    Correct. The timestamp is a UNIX timestamp. That is - the number of whole seconds since Jan 1, 1970 UTC, not accounting for leap seconds.

    You can verify the timestamp using a site like epochconverter.com

    1388613600 = 2014-01-01T22:00:00Z
    

    Then you can check the time zone details at timeanddate.com.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。