Php 日期格式,但不包括完整的月份名称

Php 日期格式,但不包括完整的月份名称,php,mysql,Php,Mysql,我需要这个: 12 November, 1997 要重新格式化为: 1997-11-12 为了包含在MySQL数据库中,但我正在努力使用完整的月份名称,这可能吗 谢谢 Darren如果你有PHP>=5.3,你可以使用Hacky方法: $timestamp = strtotime('12 November, 1997'); $sql = "INSERT INTO table (datefield) VALUES (FROM_UNIXTIME($timestamp))"; 有点不那么老套: $

我需要这个:

12 November, 1997
要重新格式化为:

1997-11-12
为了包含在MySQL数据库中,但我正在努力使用完整的月份名称,这可能吗

谢谢

Darren

如果你有PHP>=5.3,你可以使用Hacky方法:

$timestamp = strtotime('12 November, 1997');
$sql = "INSERT INTO table (datefield) VALUES (FROM_UNIXTIME($timestamp))";
有点不那么老套:

$timestamp = DateTime::CreateFromFormat('j F, Y', '12 November, 1997')->format('U');
$sql = "same as above";

返回
1997-11-12
,正是您需要的:)

这应该适合您:

date("Y-m-d", strtotime(12 November, 1997));

你看过这个帖子吗?不确定这是否有助于您投票关闭。有一堆带有php标记的日期转换问题。@迈克B-我同意,我写了一个血腥的问题-我确实搜索了,但没有使用正确的词,显然,我看到了错误,现在也将投票结束。@DarrenSweeney你不会找到与你的问题完全匹配的答案。但是,如果您通过投票浏览前5个[php]和[date]问题,您会发现90%的人支持php的日期/时间函数,以及如何将它们应用于您的特定问题。
date("Y-m-d", strtotime(12 November, 1997));
$tempDate = '2013-06-09';
$day = date('l', strtotime( $tempDate));// will gives you the week day name 
$month = date('jS F Y',strtotime($tempDate));// will format like date 9th June 2013