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 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动