問題描述
我現在正在使用 API,它提供了一個 epochTime.我已經嘗試了一切將這個紀元轉換為日期,但它似乎不起作用,包括 $epoch_time/1000
然后使用 date()
函數進行轉換它.
I'm using an API right now and it provides an epochTime. I've tried everything to convert this epochtime to date, but it doesn't seem to be working including $epoch_time / 1000
and then using the date()
function to convert it.
紀元時間看起來像這樣 1353430853299.有沒有辦法做到這一點?strtotime()
也不起作用.
The epoch time looks something like this 1353430853299. Is there a way to do this? strtotime()
did not work either.
似乎所有其他關于紀元時間的讀物都是關于將日期更改為紀元時間,但我希望反過來.任何幫助是極大的贊賞.
It seems that all of the other readings about epoch time are about changing date to epochtime, but I'm looking to go the other way around. Any help is greatly appreciated.
推薦答案
使用 substr($epoch, 0, 10) 修復它,然后對任何想知道 13 位紀元時間的人使用日期函數.
Fixed it using substr($epoch, 0, 10) and then used the date function for anyone wondering about the 13 digit epoch times.
這是一個示例代碼:
echo date("Y-m-d H:i:s", substr("1477020641000", 0, 10));
// Result: 2016-10-20 20:30:41
這篇關于將紀元時間轉換為日期 PHP的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!