Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有从 GUI 获得的这个字符串:09/22/2012 (mm/dd/yyyy)。
我想将其格式化为:
date("Y-m-d"); //(the MySQL DATE format )
这样做的正确 PHP 日期函数参数应该是什么?
您还可以执行以下操作来获取 MySQL 日期格式。
echo date('Y-m-d', strtotime('09/22/2012')); // Output: 2012-09-22
希望有帮助。
你可以试试
$date = DateTime::createFromFormat("m/d/Y", "09/22/2012"); echo $date->format("Y-m-d");
输出
2012-09-22