网络编程 
首页 > 网络编程 > 浏览文章

PHP入门教程之日期与时间操作技巧总结(格式化,验证,获取,转换,计算等)

(编辑:jimmy 日期: 2024/6/3 浏览:3 次 )

本文实例讲述了PHP日期与时间操作技巧。分享给大家供大家参考,具体如下:

Demo1.php

<"htmlcode">
<"htmlcode">
<"sec" - 自 Unix 纪元起的秒数
 //"usec" - 微秒数
 //"minuteswest" - 格林威治向西的分钟数
 //"dsttime" - 夏令时修正的类型
 //print_r(gettimeofday());
 //第一数组的元素就是时间戳
 //gettimeofday() 就是取得的当前时间的时间戳
 //$a = gettimeofday();
 //sec 取得当前时间的时间戳
 //转换成人可以看得懂的时间
 //第二个参数,对于本例来讲,放与不放,是一样的。
 //echo date('Y-m-d H:i:s',$a['sec']);
 print_r(gettimeofday(0));
 echo gettimeofday(1);
"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"htmlcode">
<"tm_sec" - 秒数
 //"tm_min" - 分钟数
 //"tm_hour" - 小时
 //"tm_mday" - 月份中的第几日
 //"tm_mon" - 年份中的第几个月,从 0 开始表示一月
 //"tm_year" - 年份,从 1900 开始
 //"tm_wday" - 星期中的第几天
 //"tm_yday" - 一年中的第几天
 //"tm_isdst" - 夏令时当前是否生效
 print_r(localtime(time(),true));
 //Array ( [tm_sec] => 37 [tm_min] => 15 [tm_hour] => 19
 //[tm_mday] => 20 [tm_mon] => 3 [tm_year] => 115
 //[tm_wday] => 1 [tm_yday] => 109 [tm_isdst] => 0 )
"htmlcode">
<"_blank" href="https://www.jb51.net/Special/96.htm">php日期与时间用法总结》、《PHP数组(Array)操作技巧大全》、《PHP基本语法入门教程》、《PHP运算与运算符用法总结》、《php面向对象程序设计入门教程》、《PHP网络编程技巧总结》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

上一篇:PHP入门教程之表单与验证实例详解
下一篇:PHP入门教程之正则表达式基本用法实例详解(正则匹配,搜索,分割等)