标签:strtotime php date time type-conversion
<?php
echo strtotime("2014-01-01 00:00:01")."<hr>";
// output is 1388516401
?>
如果它可以逆转,我会感到惊讶.我的意思是我可以将1388516401转换为2014-01-01 00:00:01.
我真正想知道的是,这种转换背后的逻辑是什么. php如何将日期转换为特定的整数.
解决方法:
是的,你可以将其转换回来.你可以试试:
date("Y-m-d H:i:s", 1388516401);
这个从date转换为整数的逻辑在strtotime中用PHP解释:
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.
例如,strtotime(“1970-01-01 00:00:00”)给你0和strtotime(“1970-01-01 00:00:01”)给你1.
这意味着如果您打印strtotime(“2014-01-01 00:00:01”),它将输出1388516401,所以日期2014-01-01 00:00:01是1970年1月1日之后的1,388,516,401秒00 :00:00 UTC
标签:strtotime,php,date,time,type-conversion 来源: https://codeday.me/bug/20190930/1836669.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。