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.
我有一个网站,人们加入并输入他们的生日,我想将其作为日期类型存储在 MySQL 中。
我拥有的数据是
Day - eg: 1 or 11, 23 etc Month - eg: March or April or December Year - eg: 1975 or 1964 or 1944 etc thus eg: 3 March 1966
如何将其转换为可以保存为 MySQL 日期类型的格式?
谢谢你
$datetime = DateTime::createFromFormat('j F Y', '3 March 1966'); echo $datetime->format('Y-m-d');
看到它在行动
参考:
它可以使用 date() 和 strtotime() 函数创建
$mysql_date= date("Y-m-d",strtotime("3 March 1996"));
工作演示