类DateTime的对象无法在我的代码中转换为字符串

时间:2013-07-29 01:46:35

标签: php mysql datetime

捕获致命错误:类DateTime的对象无法转换为字符串

$timestamp = "$day/$month/$year 00:00:00";
$timestamp = date_create_from_format('d/m/Y H:i:s', $timestamp);

echo $timestamp->format('Y-m-d H:i:s');

我该怎么办?

1 个答案:

答案 0 :(得分:2)

$timestamp = new DateTime();
echo $timestamp->format('Y-m-d H:i:s');

你在寻找吗?