I need to construct a DateTime from an integer Unix timestamp 1329272833. The documentation says the constructor needs a “date/time” string like 2006-04-12T12:30:00. I manually did my own conversion:
$dateTimeEnd = new DateTime(
date('Y-m-d\TH-i-s', 1329272833)
);
Does PHP have a built in function to do this conversion?
You can use a timestamp as parameter if you add the
@-sign at the front:Demo. You find it documented on the manual page, see the examples.