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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题