I have the following Unix timestamps.
1301982430 1301982430 1301981474
1301981466 1301981466 1301981066
1301981058 1301981058 1301980388
1301980373 1301980373 1301979082
1301978478 1301978478 1301978478
How do I convert it back to time that's human friendly?
This doesn't seem to work,
strtotime($item->timestamp);
The getTime method returns the number of milliseconds since the Unix Epoch (1st of January, 1970 00:00:00). To get a Unix timestamp, we have to divide the result from calling the getTime() method by 1000 to convert the milliseconds to seconds. What is this?
Unix time can never go backwards, unless a leap second has been added. This one has happened in practice – 27 times at time of writing. The UTC day gets an extra second added to the end, 23:59:60.
You can simply use the fromtimestamp function from the DateTime module to get a date from a UNIX timestamp. This function takes the timestamp as input and returns the corresponding DateTime object to timestamp.
For converting 11 digits timestamp to a standard datetime, use the formula as this:=A1/864000+DATE(1970,1,1), A1 is the cell that contains the 11-digits you want to convert to.
You can use the php date function to get the date and time.
echo date('Y-m-d h:i:s',$item->timestamp);
Use date()
or strftime
.
echo strftime("%Y-%m-%d, %H:%M:%S", time());
echo date('Y-m-d, H:i:s');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With