神语

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

  strtotime() 函数 定义和用法

  strtotime() 函数将任何英文文本的日期时间描述解析为 Unix 时间戳。

  语法

  strtotime(time,now)

参数描述
time 规定要解析的时间字符串。
now 用来计算返回值的时间戳。如果省略该参数,则使用当前时间。

  例子

  

<?php

  echo(strtotime("now"));

  echo(strtotime("3 October 2005"));

  echo(strtotime("+5 hours"));

  echo(strtotime("+1 week"));

  echo(strtotime("+1 week 3 days 7 hours 5 seconds"));

  echo(strtotime("next Monday"));

  echo(strtotime("last Sunday"));

  ?>

 

  输出:

 

   1138614504

  1128290400

  1138632504

  1139219304

  1139503709

  1139180400

  1138489200

 

  说明

  该函数预期接受一个包含美国英语日期格式的字符串并尝试将其解析为 Unix 时间戳(自 January 1 1970 00:00:00 GMT 起的秒数),其值相对于 now 参数给出的时间,如果没有提供此参数,则用系统当前时间。

 

 

  date_default_timezone_get()定义和用法

  date_default_timezone_get() 函数返回脚本中所有日期时间函数所使用的默认时区。

  date_default_timezone_set('PRC'); //设置时区

posted on 2013-05-22 19:39  神语  阅读(219)  评论(0编辑  收藏  举报