在 PHP 中将 Unix 纪元时间戳转换为 MySQL 时间戳 [英] Convert Unix epoch timestamp to MySQL timestamp in PHP

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

问题描述

我有一个问题,客户端有一些旧环境(IIS 6/PHP 5.0.1)并不断收到以下错误:

I have an issue whereby a client has some legacy environment (IIS 6 / PHP 5.0.1) and keeps getting the following error:

警告:date() [function.date]:使用 date() 函数时,Windows 不支持 1970 年 1 月 1 日午夜 (00:00:00) 之前的日期.

Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in" when using the date() function.

我需要找到一种方法将我的 UNIX 时间戳,即1293559200"(2010 年 12 月 28 日)转换为我可以作为正确日期传递的内容.

I need to find a way to convert my UNIX timestamp, i.e "1293559200" (28th of Dec, 2010) to something I can then pass on as a correct date.

推荐答案

SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d %H:%i:%s');

您可以在哪里用您的时间戳值替换 UNIX_TIMESTAMP().

Where you can replace UNIX_TIMESTAMP() with your timestamp value.

这篇关于在 PHP 中将 Unix 纪元时间戳转换为 MySQL 时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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