duankuangxie9070 2015-01-12 15:16
浏览 31

为什么日期(“c”)会产生这种奇怪的结果?

$now=  date ("c");

I used a local Apache server and the result:

2015-01-12T23:12:00+08:00

Now here is a problem

Now, at my computer the hour is 22:12 not 23:12

Also my time zone is Jakarta which is +7 not +8

So why does the code produce 2015-01-12T23:12:00+08:00

My apache installation got the timezone somewhere. Somewhere wrong. Where?

  • 写回答

2条回答 默认 最新

  • dongyingming8970 2015-01-12 15:20
    关注

    Try adding date_default_timezone_set("Asia/Jakarta") at the very top of your PHP file. If that works, change your php.ini to always use the correct timezone (date.timezone="Asia/Jakarta"). That way, you'll reflect the correct timezone of the server (in this case your computer).

    To see what the time is in another timezone, you could do what N.B. suggested in the comments to this answer:

    $dt = new DateTime("now", new DateTimeZone('Europe/Paris')); //If that's the timezone.
    echo $dt->format('c');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里