php中日期处理的几个函数,小结一下
2014-05-21 21:14
435 查看
date_default_timezone_set —
设定用于一个脚本中所有日期时间函数的默认时区
//中国需要设置下时间 date_default_timezone_set ('Asia/Chongqing')或者date_default_timezone_set('PRC');
date_default_timezone_get —取得一个脚本中所有日期时间函数所使用的默认时区
1,得到当前时间戳
int time (void ), 取得当前时间时间戳
mixed gettimeofday ([
bool
数组中的键为:
"sec" - 自 Unix 纪元起的秒数
"usec" - 微秒数
"minuteswest" - 格林威治向西的分钟数
"dsttime" - 夏令时修正的类型
mixedmicrotime ([
bool
int mktime ([int
得到想要的时间对应的时间戳信息
2,得到指定时间戳对应的时间信息:
array getdate ([int
array date_parse_from_format (string
array date_parse (string
3,时间格式化函数
string date (string
string gmdate (string
基本上以上这些函数掌握了,对于php时间的操作就没有什么大问题了,额 对,差点忘了 ,还有一个比较简单的格式化的函数,
设定用于一个脚本中所有日期时间函数的默认时区
//中国需要设置下时间 date_default_timezone_set ('Asia/Chongqing')或者date_default_timezone_set('PRC');
date_default_timezone_get —取得一个脚本中所有日期时间函数所使用的默认时区
1,得到当前时间戳
int time (void ), 取得当前时间时间戳
mixed gettimeofday ([
bool
$return_float= false ] )返回一个数组,
数组中的键为:
"sec" - 自 Unix 纪元起的秒数
"usec" - 微秒数
"minuteswest" - 格林威治向西的分钟数
"dsttime" - 夏令时修正的类型
mixedmicrotime ([
bool
$get_as_float] ) 一般用来调试程序用
int mktime ([int
$hour= date("H") [,int
$minute= date("i") [,int
$second= date("s") [,int
$month= date("n") [,int
$day= date("j") [,int
$year= date("Y") [,int
$is_dst= -1 ]]]]]]] )
得到想要的时间对应的时间戳信息
2,得到指定时间戳对应的时间信息:
array getdate ([int
$timestamp= time() ] )
array date_parse_from_format (string
$format, string
$date)
array date_parse (string
$date)这两个函数返回时间信息数组,个人觉得没多大用处
3,时间格式化函数
string date (string
$format[, int
$timestamp] )
string gmdate (string
$format[, int
$timestamp] )
基本上以上这些函数掌握了,对于php时间的操作就没有什么大问题了,额 对,差点忘了 ,还有一个比较简单的格式化的函数,
相关文章推荐
- php 日期时间处理函数小结
- PHP模拟SQL Server的两个日期处理函数
- PHP 日期加减处理函数
- php中几个字符函数小结
- php 日期加减处理函数
- php处理url的几个函数
- php 时间处理函数--获取某个间隔前的日期
- php处理url的几个函数
- php对图像的各种处理函数代码小结
- PHP 正则表达式之正则处理函数小结(preg_match,preg_match_all,preg_replace,preg_split)
- oracle trunc 函数处理日期格式,日期类型很有用的几个sql
- PHP模拟SQL Server的两个日期处理函数
- php中几个字符处理函数的说明
- php对图像的各种处理函数代码小结
- PHP模拟SQL Server的两个日期处理函数
- PHP模拟SQL Server的两个日期处理函数
- oracle trunc 函数处理日期格式,日期类型很有用的几个sql
- php的日期处理函数
- php 日期加减处理函数