<?php
  // 各种时间函数
  echo "现在:".date("Y-m-d H:i:s")."<br>";
  echo "今天:".date("Y-m-d ")."<br>";
  echo "明天:".date("Y-m-d",strtotime("+1 day")), "<br>";
  echo "后天:".date("Y-m-d",strtotime("+2 day")), "<br>";
  echo "昨天:".date("Y-m-d",strtotime("-1 day")). "<br>";
  echo "前天:".date("Y-m-d",strtotime("-2 day")). "<br>";
  echo "一周后:".date("Y-m-d",strtotime("+1 week")). "<br>";
  echo "两周后:".date("Y-m-d",strtotime("+2 week")). "<br>";
  echo "一周前:".date("Y-m-d",strtotime("-1 week")). "<br>";
  echo "两周前:".date("Y-m-d",strtotime("-2 week")). "<br>";
  echo "一周零一天一小时一秒后:".date("Y-m-d G:H:s",strtotime("+1 week 1 days 1 hours 1 seconds")). "<br>";
  echo "下个星期四:".date("Y-m-d",strtotime("next Thursday")). "<br>";
  echo "上个星期四:".date("Y-m-d",strtotime("last Thursday"))."<br>";
  echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."<br>";
  echo "一个月前:".date("Y-m-d",strtotime("-1 month"))."<br>";
  echo "一个月后:".date("Y-m-d",strtotime("next month"))."<br>";
  echo "一个月前:".date("Y-m-d",strtotime("last month"))."<br>";
  echo "五年后:".date("Y-m-d",strtotime("+5 year"))."<br>";
  echo "明年:".date("Y-m-d",strtotime("+1 year"))."<br>";
  echo "去年:".date("Y-m-d",strtotime("-1 year"))."<br>";
?> 

诸如next和last等同于+1和-1的方式,可以以此类推,举一反三,常用的时间函数。

分享一些关于PHP时间函数的常用时间的更多相关文章

  1. Loadrunner时间函数、用时间生成订单编号例子

    Loadrunner中取时间函数.用时间函数生成订单编号例子: <如要转载,请注明网络来源及作者:Cheers_Lee> 问题的提出: (1)有时候在Loadrunner中用C语言设计脚本 ...

  2. MySQL时间函数-获取当前时间-时间差

    MySQL中获取当前时间为now(),不同于sqlserver getdate(). SQLServer转MySQL除变化top 1 -> limit 1之后报错: limit [Err] 15 ...

  3. Delphi 时间函数:关于时间精确的几个函数和方法

    //取毫秒级时间精度(方法一): var t1,t2:int64; r1:int64; begin t1:=GetTickCount;//获取开始计数 WINDOWS API sleep(1000); ...

  4. EL 标准格式时间 转换成 常用时间yyyy-MM-dd

    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%><fmt:format ...

  5. PLSQL常用时间函数

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  6. windows时间函数

    介绍        我们在衡量一个函数运行时间,或者判断一个算法的时间效率,或者在程序中我们需要一个定时器,定时执 行一个特定的操作,比如在多媒体中,比如在游戏中等,都会用到时间函数.还比如我们通过记 ...

  7. PHP的函数-----生成随机数、日期时间函数

    常用的函数 [1]   生成随机数 rand(); 例子: echo rand(); 显示结果: 当刷新时,会有不同的数,默认生成随机数.生成随机数不能控制范围. 如果,想要控制在范围之内,就用: e ...

  8. C中的时间函数的用法

    C中的时间函数的用法    这个类展示了C语言中的时间函数的常用的用法. 源代码: #include <ctime>#include <iostream> using name ...

  9. MySQL:日期函数、时间函数总结

    MySQL 获得当前日期时间 函数 获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+ | n ...

随机推荐

  1. joson返回数据库的时间格式在前台用js转换

    function ChangeDateFormat(val) { if (val != null) { var date = new Date(parseInt(val.replace("/ ...

  2. job

    详情见:http://blog.csdn.net/wxwzy738/article/details/25158787 spring.xml <beans xmlns="http://w ...

  3. list中的中文转换编码显示

    for i in range(1,sheet.nrows): row=sheet.row_values(i,0,sheet.ncols) row=str(row).replace('u\'','\'' ...

  4. SQLServer控制用户访问权限表

    连接地址:http://www.cnblogs.com/yxyht/archive/2013/03/22/2975880.html 一.需求 在管理数据库过程中,我们经常需要控制某个用户访问数据库的权 ...

  5. sdn

    #!/usr/bin/env python #from mininet.cli import CLI #from mininet.link import Link #from mininet.net ...

  6. readline,readlines,read函数

    readline是读取每一行,包括'\n'.读出来是一个含'\n'的字符串. realines是读取整个文件,返回所有行的一个list(写代码的时候你需要一个文件的某几行,就可以用这个函数去切分) r ...

  7. cocos IDE 编译lua 游戏程序的环境配置

    因为毕业设计需要用cocosIDE编译一个apk在手机上跑,所以搭建这个环境还是需要的. ps:是针对win系统的. 需要的工具: 1.cocosIDE:点击链接 (ps:据说这个软件设计有点反人类, ...

  8. Radmin Center 1.54 测试版

    软件简介:radmin center 用于集中管理安装了 radmin server 的服务器,支持一键远程管理,数据全部本地存储,关键数据使用RC4变形加密.同时保留了radmin的高安全性和高易用 ...

  9. MySQL显示中文

    http://www.cnblogs.com/livingintruth/p/3433259.html 这两天在学习webpy,把webpy的一个blog例子扒下来学习一下,默认创建的table当存入 ...

  10. 简单的方式优化mysql

    参考博客 自己笔记本上向mysql导入txt数据,有一个table导入了将近4个小时,而且多个table之间都是相互之间存在关系的,所以做联合查询的时候你会发现问题会十分的多,我之前联合查询两个表就死 ...