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条)

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题