【发布时间】:2014-08-31 16:04:56
【问题描述】:
我有以下格式的日期
31st of August 2014 Sun 使用 $cursor->format("jS \of F Y D"); 但如何将现有时间转换为 Ymd 以便输出为 20140831
我试过echo date("Y-m-d", strtotime(31st of August 2014 Sun));
而且我不知道为什么输出显示为 1970 年 1 月 1 日,这很奇怪。
我也试过了
echo contime('1st of August 2013 Sun');
function contime($gettime) {
$fetch_date = strtotime($gettime);
$date = new DateTime('');
return $date->format('Ymd');
}
但这是返回今天的日期。
也试过Convert one date format into another in PHP
$old_date = date('1st of August 2013 Sun'); //date('l, F d y h:i:s'); // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('Y-m-d H:i:s', $old_date_timestamp);
echo $new_date;
但它的打印1970-01-01 00:00:00
【问题讨论】: