I am working on a project and I am having an issue formatting an epoch time to a human readable time.
I have the following epoch time 1428512160
and when I put this through epochconverter.com I get the human time of 08/04/2015 17:56:00 GMT+1:00 DST
as expected.
I then use the following code in order to perform the conversion from the epoch time to a human date time.
$dt = new DateTime($supportDetails["Reported"]);
$reportedTimeString = $dt->format('d-m-Y H:i:s');
$supportDetails[Reported] is the epoch time (I've printed it so I know it's correct).
The result I get back however is 08-04-2160 14:28:51
.
You need to add an
@
for the timestamp in the DateTime class, like this:You can also see this in the manual. And a quote from there:
Also note that the current timezone is getting ignored, which you can also see in the manual: