php日期转换不正确


php date not converting properly

我在php中有这个日期:2013年1月31日

我正在尝试使用strtotime函数来转换它,就像一样

date("Y-m-d", strtotime(31/01/2013));

但一直显示为1970-01-01。知道为什么吗?

您应该将它包含在一个字符串中,而不是一个连续的除法序列

date("Y-m-d", strtotime("31/01/2013"));

这将适用于

$date = str_replace("/", "-", "31/01/2013");
echo date("Y-m-d", strtotime($date));

试试这个

$date = "31/01/2013";
$date = date("Y-m-d", strtotime($date));

希望它能帮助

试试这个

$date = "01/08/2013";
echo date('Y-m-d', $date);