教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 使用strtotime和mktime时参数为0时返回1999-11-30的时间戳问题

使用strtotime和mktime时参数为0时返回1999-11-30的时间戳问题

发布时间:2018-10-16   编辑:jiaochengji.com
教程集为您提供使用strtotime和mktime时参数为0时返回1999-11-30的时间戳问题等资源,欢迎您收藏本站,我们将为您提供最新的使用strtotime和mktime时参数为0时返回1999-11-30的时间戳问题资源
本文章来给各位朋友分析关于使用strtotime和mktime时参数为0时返回1999-11-30的时间戳问题解决方法,希望本文章对大家会有所帮助。

先看例子

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy3645')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3645>

<?php
$time = date('Y-m-d',strtotime('00-00-00 00:00:00'));
echo $time;
//输出 1999-11-30
?>

这里没有任何bug,00-00-00的意思是2000-00-00,2000-00-00实际上是1999-12-00,而1999-12-00又会转换成1999-11-30。
所以这里没有任何bug,完全正常。

strtotime('00-00-00 00:00:00')与 mktime(0,0,0,0,0,0) 是完全等价的。

//int mktime(时, 分, 秒, 月, 日, 年)
echo mktime(0,0,0,0,0,0);
mktime() 函数用于从日期取得时间戳,成功返回时间戳,否则返回 FALSE 。

输出 943920000

您可能感兴趣的文章:
使用strtotime和mktime时参数为0时返回1999-11-30的时间戳问题
php中time()和mktime()用法的区别分析
php中的UNIX时间戳函数strtotime
php 时间戳函数总结与示例
php中什么是时间戳?
php日期与时间运算实例分享
php 获取今日、昨日、上周、本月的起始与结束时间戳
php字符串转时间戳
php时间转换unix时间戳实例
php时间戳转换

[关闭]
~ ~