我试图将月,日和年转换为Unix时间戳。
<?php
day = '30' ;
$month = 'November' ;
$year = '2016' ;
$t = date('H:i');
$quoteDate = strtotime("$year-$month-$day $t");
?>
此代码提供正确的年份但错误的日期和月份。
答案 0 :(得分:0)
我认为您应该尝试使用DateTime
代替,可以按摩来处理那种日期字符串
$day = '30' ;
$month = 'November' ;
$year = '2016' ;
$t = date('H:i');
$quoteDate = DateTime::createFromFormat("Y-F-d H:i", "$year-$month-$day $t");
echo $quoteDate->format('Y-m-d H:i:s');
您可以在此处查看演示https://3v4l.org/adJ5P