(3)php日期和时间

来源:互联网 发布:sql默认值 编辑:程序博客网 时间:2024/04/20 06:35
///----------------------------------------------------------------------------//目录checkdate -- 验证一个格里高里日期date_default_timezone_get -- 取得一个脚本中所有日期时间函数所使用的默认时区date_default_timezone_set -- 设定用于一个脚本中所有日期时间函数的默认时区date_sunrise -- 返回给定的日期与地点的日出时间date_sunset -- 返回给定的日期与地点的日落时间date -- 格式化一个本地时间/日期getdate -- 取得日期/时间信息gettimeofday -- 取得当前时间gmdate -- 格式化一个 GMT/UTC 日期/时间gmmktime -- 取得 GMT 日期的 UNIX 时间戳gmstrftime --  根据区域设置格式化 GMT/UTC 时间/日期 idate -- 将本地时间日期格式化为整数localtime -- 取得本地时间microtime -- 返回当前 Unix 时间戳和微秒数mktime -- 取得一个日期的 Unix 时间戳strftime -- 根据区域设置格式化本地时间/日期strptime -- 解析由 strftime() 生成的日期/时间strtotime -- 将任何英文文本的日期时间描述解析为 Unix 时间戳time -- 返回当前的 Unix 时间戳///----------------------------------------------------------------------//显示网页的最新修改日期int getlastmod();//返回时间戳一般配合date()使用。确定当前月份的天数date("t");确定任意给定月份的天数$lastday=mktime(0,0,0,2,1,2010);//返回时间戳printf("there are %d days in february 2010",date("t",$lastday));计算当前日期后x天的日期int strtotime ( string time [, int now] )//因为返回的是时间戳,所以通常是和date()函数配合使用本函数预期接受一个包含美国英语日期格式的字符串并尝试将其解析为 Unix 时间戳(自 January 1 1970 00:00:00 GMT 起的秒数),其值相对于 now 参数给出的时间,如果没有提供此参数则用系统当前时间<?phpecho strtotime("now"), "\n";echo strtotime("10 September 2000"), "\n";echo strtotime("+1 day"), "\n";echo strtotime("+1 week"), "\n";echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";echo strtotime("next Thursday"), "\n";echo strtotime("last Monday"), "\n";?> ///----------------------------------------------------------------//<?php日期对象object DateTime([string time [,DateTimeZone timezone]]);$date=new DateTime();echo $date->format("Y-m-d h:i:sa");//这里的参数和date()的参数是一样的实例化后设置日期Boolean setDate(inteter year,inteter month,inteter day);$date->setDate(2014,2,25);设置时间Boolean stream_set_timeout(stream, seconds)(inteter hour,inteter minute[,inteter second]);$date->setTime(20,55);修改日期和时间$date->modify("+27 hours");//参数类似与strtotime()的///-------------------------------------------------------------//

0 0