合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[TOC] ## int <span style="color:red;">**time**</span>(void ) 返回当前的 Unix 时间戳 返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的秒数 ## int <span style="color:red;">**mktime**</span>(int 时, int 分, int 秒, int 月, int 天, int 年, int $is_dst ) 取得一个日期的 Unix 时间戳(参数都是可选得) ``` mktime(0, 0, 0, 4, 25, 2012); ``` <span style="color:red;"></span> ## int <span style="color:red;">**strtotime**</span>() 将任何英文文本的日期时间描述解析为 Unix 时间戳 ``` echo strtotime(""now""); echo strtotime(""10 September 2000""); echo strtotime(""+1 day""); echo strtotime(""+1 week""); echo strtotime(""+1 week 2 days 4 hours 2 seconds""); echo strtotime(""next Thursday""); echo strtotime(""last Monday"");" int strtotime ( string $time [, int $now ] ) ``` ## string <span style="color:red;">**date**</span>($format,$intstamp=time()) 格式化一个本地时间/日期 ``` date('Y年m月d日 H:i:s'); //2018年04月25日 20:45:54 date('Y年m月d日 H:i:s', time()); //2018年04月25日 20:45:54 date('Y-m-01'); //当月第一天 date('Y-m-t'); //当月最后一天 ``` ## **checkdate**() 验证一个格里高里日期 ``` if(checkdate(6,31,2012)){ echo '成立'; }else{ echo '不成立'; } ``` ## **microtime**() 返回当前 Unix 时间戳和微秒数 ``` $start=microtime(true); sleep(3); $stop=microtime(true); echo $stop-$start;" mixed microtime ([ bool $get_as_float ] ) ``` ## bool <span style="color:red;">**date_default_timezone_set**</span>(string $timezone_identifier) 设定用于一个脚本中所有日期时间函数的默认时区 ``` date_default_timezone_set('PRC'); ``` ## bool **checkdate**( int $month , int $day , int $year ) 如果给出的日期有效则返回 TRUE,否则返回 FALSE ## array **getdate** ([ int $timestamp ] ) 取得日期/时间信息; 返回一个根据 timestamp 得出的包含有日期信息的结合数组。如果没有给出时间戳则认为是当前本地时间 ``` $t=getdate(); var_dump($t);" ``` ## **cal_days_in_month** (CAL_GREGORIAN,$month,$year); 返回给定月份的最后一天(需要手动开启扩展,不推荐) ``` cal_days_in_month(CAL_GREGORIAN,12,2020); //推荐 date('t', time()) ```