【问题标题】:Best way to change Twitter-API datetime's to a timestamp将 Twitter-API 日期时间更改为时间戳的最佳方法
【发布时间】:2011-10-13 00:07:27
【问题描述】:

Twitter API 发送 created_at 日期时间如下:

"created_at": "Mon Jul 25 05:51:34 +0000 2011", 

将它们转换为时间戳和我的本地时区(欧洲/苏黎世)的最佳方法是什么?使用 strtotime(),我得到类似 2013-11-08 20:07:00

的结果

非常感谢

最好的问候

【问题讨论】:

    标签: php datetime timestamp strtotime


    【解决方案1】:
    $datetime = new DateTime("Mon Jul 25 05:51:34 +0000 2011");
    $datetime->setTimezone(new DateTimeZone('Europe/Zurich'));
    echo $datetime->format('U');
    

    DateTimeDateTime::format()DateTime::setTimezone()DateTimeZonedate()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      相关资源
      最近更新 更多