且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP date_format():如何从字符串值格式化日期

更新时间:2022-06-05 22:35:14

首先使用 createFromFormat 方法,提供输入格式:

Use createFromFormat method first, provide the input format:

$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;