doushang9172 2013-09-18 12:32
浏览 44

PHP时区冲突

I have set my date.timezone setting in my php.ini directory as follows

date.timezone = "Asia/Kolkata"

When I run mktime using following parameters

mktime(0,0,0,10,11,1993);

The timestamp i get is 752907600

But when i precede the mktime function with date_default_timezone_set('Asia/Kolkata'); it gives me the expected output timestamp i.e. 752869800

If both the timezones are same then why is the output different?

----------------EDIT--------------------------

Ok I got the problem, but I dont know why is it occuring

echo date_default_timezone_get().'<br />';
echo mktime(0,0,0,11,10,1993).'<br />';
date_default_timezone_set('Asia/Kolkata');
echo date_default_timezone_get().'<br />';
echo mktime(0,0,0,11,10,1993);

output

EST5EDT
752907600
Asia/Kolkata
752869800

I have set the .ini settings correctly then what may be the problem?

  • 写回答

1条回答 默认 最新

  • dongxuan2015 2013-09-30 07:56
    关注

    Ok I got the problem, but I dont know why is it occuring

    Like you already see in your code, it is timezone issue. mktime and strtotime functions are timezone/offset aware. Function time() on other hand is not influenced by timezone offset.

    If you need mktime() that will always return GMT/UTC date, you can use gmmktime().

    评论

报告相同问题?

悬赏问题

  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测