【发布时间】:2015-10-09 20:11:14
【问题描述】:
我正在尝试将月、日和年转换为 Unix 时间戳。
<?php
day = '30' ;
$month = 'November' ;
$year = '2016' ;
$t = date('H:i');
$quoteDate = strtotime("$year-$month-$day $t");
?>
此代码给出正确的年份,但错误的日期和月份。
【问题讨论】:
-
你确定你的帖子值是正确的吗?发布样本值,以便我们对其进行测试。
-
是的。我检查过了。请检查已编辑的问题。
-
mktime 是一种更精确的方法来处理这个问题,不是吗? php.net/manual/en/function.mktime.php
-
这不是 strtotime 解析的有效日期格式
-
我从这个页面得到了那个代码stackoverflow.com/questions/6208484/…