dongyun3805 2013-07-07 10:05 采纳率: 0%
浏览 21
已采纳

根据服务器时区动态打印时间

I've read many posts about the question I posted here but I'm encountering a strange issue.

I've set my PHP server timezone to "Asia/Bangkok" (just an example) using date.timezone directive in php.ini file which works quite fine.

The server returns correct time based on set time zone when I simply print the time as

<?php echo date("F j, Y, g:i A"); ?> 

But when I want to print a series of time dynamically, inputted into mysql database during user entry like,

<?php echo date("F j, Y g:i A", strtotime($row_entries['input_time']));?>

The server returns the system time based on the timezone set by host which is Europe/Dublin (just an example).

I even tried to print the time without strtotime function like,

 <?php echo date("F j, Y g:i A",($row_entries['post_time']));?>

That returns abnormal/invalid date.

What's going wrong here and how could I print time dynamically based on server time zone I set in php.ini?

  • 写回答

3条回答 默认 最新

  • doudou20145 2013-07-07 10:10
    关注

    It seems that this row

    $row_entries['post_time']
    

    uses MYSQL default time zone which is different

    so please could you post SQL that insert data in this column ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染