时间加减
-
<?php
-
-
$date=date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")+1));
-
?>
如果要获取数据库中的时间应该如何处理呢?在PHP文档中找到了一个很好的函数strtotime,可以对时间进行加减:
-
intstrtotime(stringtime[,intnow])
返回类型 int函数可用于时间转换和加减。
-
<?php
-
-
-
$date_year=date('Y-m-d',strtotime("$date+1year"));
-
echo$date_year;
-
-
$date_tomorrow=date('Y-m-d',strtotime("2009-05-26+1day"));
-
echo$date_tomorrow;
-
-
$date_week=date('Y-m-d',strtotime("$date+1week"));
-
echo$date_week;
-
?>
$time = strtotime('2014-06-10 00:06:00');
var_dump($time); //int 1402358760
分享到:
相关推荐
在PHP中有个叫做strtotime的函数。strtotime 实现功能:获取某个日期的时间戳,或获取某个时间的时间戳。strtotime 将任何英文文本的日期时间描述解析为Unix时间戳[将系统时间转化成unix时间戳] 一,获取指定日期的...
本文实例讲述了PHP中时间加减函数strtotime用法。分享给大家供大家参考,具体如下: 时间加减 <?php //获取本地 提取年份+1 $date=date("Y-m-d",mktime(0,0,0,date("m") ,date("d"),date("Y")+1)); ?> 如果...
使用strtotime可以将各种格式的时间字符串转换为时间戳 转换常规时间格式 echo date('Y-m-d H:i:s', strtotime('2016-01-30 18:00')).PHP_EOL; echo date('Y-m-d H:i:s', strtotime('20160130180001')).PHP_EOL; ...
本文实例讲述了php使用date和strtotime函数输出指定日期的方法。分享给大家供大家参考。具体方法分析如下: 在php中date和strtotime函数都是对日期操作的,但是在生成上面date和strtotime是不一样的,一个是数字日期...
PHP中strtotime函数使用方法.docx
document.write(strtotime('now')); document.write(strtotime('next Sunday')); document.write(strtotime('last month')); document.write(strtotime('+1 weeks')); document.write(strtotime('+1 WEEK')); ...
strtotime()是php中的时间函数;其功能是:将任何字符串形式的日期,时间转换成对应的Unix 时间戳。今天我们是通过具体的实例来详细分析下strtotime()函数的性能问题
strtotime函数是一个很好的函数,灵活的运用它,会给你的工作带来不少方便.但PHP的手册中却对此函数的参数没作太多介绍,对些函数的其他介绍也非常少。
在php中我想要获取时间戳有多种方法,最常用的就是使用time函数与strtotime()函数把日期转换成时间戳了,下面我来给大家分享一下时间戳函数 strtotime用法。获取指定的年月日转化为时间戳:pHP时间戳函数获取指定...
主要介绍了php中strtotime函数的用法,以实例形式详细分析了strtotime函数的参数含义与相应的用法,适用于时间格式变换的情况,需要的朋友可以参考下
本篇文章是对php strtotime函数的使用进行了详细的分析介绍,需要的朋友参考下
主要介绍了PHP strtotime函数用法、实现原理和源码分析,本文讲解了strtotime函数的一些用法、strtotime函数的实现基本原理、strtotime(“-1 month”)求值失败的原因等内容,需要的朋友可以参考下
int strtotime ( string time [, int now])本函数预期接受一个包含英文日期格式的字符串并尝试将其解析为 UNIX 时间戳。
一,获取指定日期的unix时间戳 strtotime(“2009-1-22”) 示例如下: 1.echo strtotime(“2009-1-22”) 结果:1232553600 说明:返回2009年1月22日0点0分0秒时间戳 二,获取英文文本日期时间 示例如下: 便于比较,...