我想要的時間格式是2016-01-19T06:22:00.000Z
(YYYY-MM-DDThh:mm:ss.sssZ);但是,我得到這種格式:2016-01-19T06:22:00+01:00
。PHP轉換爲YouTube時間格式(ISO 8601)
這裏是我的代碼:
$before = "2016-01-19 06:22:00";
$after = date('c', strtotime($before));
echo "Before: $before\n";
echo "After: $after";
這裏的fiddle。
http://php.net/manual/en/function.date.php#115228 – CBroe
@CBroe,感謝,但'$ =之後(新的DateTime($ before)) - > format(DateTime :: ISO8601);'產生'2016-01-19T06:22:00 + 0100'。我需要它的格式與「2016-01-19T06:22:00.000Z」完全一樣,因爲YouTube不接受其他格式的我。 – Pamela
那麼你可以很容易地創建它自己,通過將其他格式字符代表的個別日期部分以正確的順序放在一起。 – CBroe