This question already has an answer here:
How do I convert this date: 1427510741
to: 2015-03-22 09:27:02
in PHP?
I tried: $date2 = new DateTime($date1);
but it gives me: 0741-04-08
And I want this: 2015-03-22 09:27:02
</div>
This question already has an answer here:
How do I convert this date: 1427510741
to: 2015-03-22 09:27:02
in PHP?
I tried: $date2 = new DateTime($date1);
but it gives me: 0741-04-08
And I want this: 2015-03-22 09:27:02
</div>
You're close. To use a Unix Timestamp with DateTime to must prepend an @
before the timestamp:
$date2 = new DateTime('@'.$date1);