将纪元时间转换为日期 PHP

Convert Epoch Time to Date PHP(将纪元时间转换为日期 PHP)
本文介绍了将纪元时间转换为日期 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) 修复它,然后对任何想知道 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)