我有一些PHP代码:
$exd = date_create('01 Dec, 2015');
$exd = date_format($exd, 'Y-m-d');
echo $exd;
用于格式化日期。预期的输出为,2015-12-01
但返回2016-12-01
。我想念什么?
createFromFormat
首先使用方法,提供输入格式:
$exd = DateTime::createFromFormat('d M, Y', '01 Dec, 2015');
// arguments (<format of the input>, <the input itself>)
$exd = date_format($exd, 'Y-m-d'); // then choose whatever format you like
echo $exd;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句