douyoufan7881 2014-12-08 13:29
浏览 8

日期时间错误[重复]

This question already has an answer here:

i have some trouble with an script part.

The part is this:

$datetime = date('d.m.Y \u\m H:i \U\h', substr($row['expires'], 0, -3));
echo "<td>$datetime</td>";

The script result:

http://fs1.directupload.net/images/141208/swk8pe2s.jpg

The full script:

http://pastie.org/9767822

The problem:

Its the wrong time... its the 08.12.2014 not 11.12.2014 I dont know what is wrong, can anybody please help?

</div>
  • 写回答

1条回答 默认 最新

  • 普通网友 2014-12-08 13:38
    关注

    Can we see where $row is coming from? i.e. can you post some rows from your database? My guess would be that the value passed from $row['expires'] is not what you are expecting, and hence causing $datetime to have an unexpected value. Try the following:

    $datetime = date('d.m.Y \u\m H:i \U\h', strtotime(substr($row['expires'], 0, -3)));
    

    If that still produces incorrect results, the time is probably being saved incorrectly in the first place (keep in mind that you might need to set the timezone for your script to use)

    If you don't get it right with the code above, please post an example of a row that is being passed into $row so that we can see what the input is. Your syntax looks pretty correct, so I would think the problem is the data that is being passed to the script.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?