問(wèn)題描述
我現(xiàn)在正在使用 API,它提供了一個(gè) epochTime.我已經(jīng)嘗試了一切將這個(gè)紀(jì)元轉(zhuǎn)換為日期,但它似乎不起作用,包括 $epoch_time/1000
然后使用 date()
函數(shù)進(jìn)行轉(zhuǎn)換它.
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.
紀(jì)元時(shí)間看起來(lái)像這樣 1353430853299.有沒(méi)有辦法做到這一點(diǎn)?strtotime()
也不起作用.
The epoch time looks something like this 1353430853299. Is there a way to do this? strtotime()
did not work either.
似乎所有其他關(guān)于紀(jì)元時(shí)間的讀物都是關(guān)于將日期更改為紀(jì)元時(shí)間,但我希望反過(guò)來(lái).任何幫助是極大的贊賞.
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) 修復(fù)它,然后對(duì)任何想知道 13 位紀(jì)元時(shí)間的人使用日期函數(shù).
Fixed it using substr($epoch, 0, 10) and then used the date function for anyone wondering about the 13 digit epoch times.
這是一個(gè)示例代碼:
echo date("Y-m-d H:i:s", substr("1477020641000", 0, 10));
// Result: 2016-10-20 20:30:41
這篇關(guān)于將紀(jì)元時(shí)間轉(zhuǎn)換為日期 PHP的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!