《php源码学习研究》 第四天 strtotime() 函数 date_default_timezone_get()

  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 神语 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/sichunlei/archive/2013/05/22/3093406.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值