dongqiao1151 2012-09-20 22:42
浏览 115
已采纳

php strtotime拼图 - 夏令时?

PHP CODE

$t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' );
$t2 =  date('c',$t);
echo $t2; 

OUPUT

 2012-09-20T23:00:00-04:00

QUESTION

Chicago's timezone is UTC-5, why don't I get 2012-09-20T22:00:00-05:00 as the result?

  • 写回答

2条回答 默认 最新

  • duanshan3331 2012-09-20 23:02
    关注

    strtotime converts to a Unix timestamp. date will convert the timestamp to a string using the current time zone. Try setting your time zone first.

    $t = strtotime( '2012-09-21T03:00:00+00:00 America/Chicago' );
    date_default_timezone_set('America/Chicago');
    $t2 =  date('c',$t);
    echo $t2;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题