dsy19890123 2016-07-05 02:37
浏览 64
已采纳

Php日期从数据库信息中添加一天

I have this line of code:

<?= date('F dS, Y',$user_info['date_of_birth']) ?>

It gets the unix birtday date per user and converts it in a normal date. The only problem is that it will show one day earlier. For example, the unix date in the database is 11th may 1990. In the view it will output, 10th may 1990. Do you know how to fix this issue?

Thanks in advance

  • 写回答

3条回答 默认 最新

  • douyi7055 2016-07-05 04:35
    关注

    To explicitly answer your question, you can do the following:

    <?=date('F dS, Y',($user_info['date_of_birth'] + 86400))?>
    

    Where 86400 is the number of seconds in a day.


    However, as others suggested, you can and should sync up the database and Php to UTC/GMT time.

    For Php timezone, do the following at top of your scripts:

    date_default_timezone_set('UTC');
    

    For SQL, that depends on the database you're using (I don't believe you specified the database you're using).

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

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路