dthok9648 2012-10-29 13:45
浏览 34
已采纳

php在我的时区获取日期

I'm new to php. I was able to get the time but the problem is it's in different time zone. What I want is to get the time in my timezone. Here's my code:

<?php
date_default_timezone_set('UTC+8');
$mydate=date('h:i A');
?>

The codes above gives me the wrong time, my timezone is UTC+8. Example my time is 9:00PM, but the codes above returns 1:00PM. How could I fix this? Any help would be so much appreciated.

UPDATE: I got it working now (thanks to @enenen). My new code that returns the correct timezone in my area:

<?php
date_default_timezone_set('Asia/Manila');
$mydate=date('h:i A');
?>
  • 写回答

4条回答 默认 最新

  • dongnaigu2052 2012-10-29 13:50
    关注

    I think you are looking for

    date_default_timezone_set('Etc/GMT+8');
    

    or

    date_default_timezone_set('Asia/Manila');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献