【发布时间】:2017-01-02 20:49:30
【问题描述】:
我以以下格式将单圈时间存储在数据库中:103.900。
我使用以下日期格式从数据库中输出时间:
date('i:s.U', $video->best_lap)
我得到的是:01:43.103。实际输出时间应显示为 01:43.900。有什么办法可以让 PHP 玩的很好?
【问题讨论】:
-
来自PHP Docs:
Note: Since this function only accepts integer timestamps the u format character is only useful when using the date_format() function with user based timestamps created with date_create().考虑改用 DateTime 及其format()方法 -
谢谢马克,但我不确定这有什么帮助? @马克
-
对于这样的事情,我建议以十分之一秒为单位存储时间,然后在从数据库中提取时间或之后进行转换。
-
它的帮助如下:
$dto = DateTime::createFromFormat('U.u', '103.900'); var_dump($dto->format('i:s.u')); -
@Mark 你能把它作为答案提交给你吗?效果很好!