将时代时间转换为日期PHP [英] Convert Epoch Time to Date PHP

查看:99
本文介绍了将时代时间转换为日期PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用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)修复该问题,然后将date函数用于任何想知道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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆