php strtotime 函数UNIX时间戳

yipeiwu_com6年前PHP代码库
如果 time 的格式是绝对时间则 now 参数不起作用。如果 time 的格式是相对时间则其所相对的时间由 now 提供,或者如果未提供 now 参数时用当前时间。失败时返回 -1。

<?php
echo strtotime ("now"), "\n";
echo strtotime ("10 September 2000"), "\n";
echo strtotime ("+1 day"), "\n";
echo strtotime ("+1 week"), "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime ("next Thursday"), "\n";
echo strtotime ("last Monday"), "\n";
?><?php
$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo "The string ($str) is bogus";
} else {
echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}
?>
这个效果和用mktime()是一样的.

相关文章

php mssql扩展SQL查询中文字段名解决方法

一、问题: 数据库是MS SQLServer2000,要把SQLServer2000里的一张表的数据导入MySQL5,其中SQLServer2000表的字段以简体中文命名(强烈建议不要以...

wordpress自定义标签云与随机获取标签的方法详解

wp_tag_cloud() 函数的作用是用来标签云的,可以根据每个标签所关联的文章次数来定义字体大小、标签排序等属性。从 2.8 版本开始,添加了 分类法(taxonomy)参数,这就...

php常用Output和ptions/Info函数集介绍

flush函数:刷新输出缓冲ob_clean函数:清空输出缓冲ob_end_clean函数:清空缓冲区并且关闭正在进行的输出缓冲ob_end_flush函数:发送缓冲区数据并且关闭缓冲区...

php设计模式 Decorator(装饰模式)

复制代码 代码如下: <?php /** * 装饰模式 * * 动态的给一个对象添加一些额外的职责,就扩展功能而言比生成子类方式更为灵活 */ header("Content-ty...

PHP __autoload函数(自动载入类文件)的使用方法

这也是OO设计的基本思想之一。在PHP5之前,如果需要使用一个类,只需要直接使用include/require将其包含进来即可。下面是一个实际的例子: 复制代码 代码如下: class...