从这样的日期2011-02-27 02:04:46是否可以获得UNIX时间? [英] Is it possible to get UNIX time from such date 2011-02-27 02:04:46?

查看:53
本文介绍了从这样的日期2011-02-27 02:04:46是否可以获得UNIX时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mktime和其他功能针对诸如2011-02-27 02:04:46;之类的日期给出了错误的答案.

Mktime and other functions give wrong answer for such a date like 2011-02-27 02:04:46;

推荐答案

只需使用 strtotime() a>函数,或 DateTime 类.

Just use the strtotime() function, or the DateTime class.


以下两个代码部分:


Both the two following portions of code :

echo strtotime('2011-02-27 02:04:46');

$dt = new DateTime('2011-02-27 02:04:46');
echo $dt->format('U');

将为您提供相同的输出:

Will give you the same output :

1298768686

这篇关于从这样的日期2011-02-27 02:04:46是否可以获得UNIX时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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