php 常用日期时间值
date(‘Y-m-d h:i:s’,time()) | 2014-09-12 06:28:32 |
date(‘Y-m-d’,time()) | 2014-09-12 |
date(‘Y-m-d’,strtotime(date(‘Y-m-d’, time()-86400))) | 上一天2014-09-11 |
date(‘Ymd’,time()) | (年月日,无间隔):20140912 |
date(‘m-d’,time()) | (月日,“-”间隔):09-12 |
str_replace(“-“,”月”,date(‘m-d’,time()-date(‘w’,time())*86400)).”日” | (月日,汉字显示间隔):09月12日 |
date(‘w’,time()) | (星期几):5 |
time() | UNIX时间戳 显示:1410503809 |
strtotime(date(‘Y-m-d’,time())) | (当前日期秒数,具体到天):1410503809 |
mktime(0,0,0,date(‘m’),date(‘d’),date(‘Y’)) | 当天开始的时间戳 |
mktime(0,0,0,date(‘m’),date(‘d’)+1,date(‘Y’))-1 | 当天结束的时间戳 |
mktime(0,0,0,date(‘m’),date(‘d’)-1,date(‘Y’)) | 昨天开始的时间戳 |
mktime(0,0,0,date(‘m’),date(‘d’),date(‘Y’))-1 | 昨天结束的时间戳 |
mktime(0,0,0,date(‘m’),date(‘d’)-date(‘w’)+1-7,date(‘Y’)) | 上周开始的时间戳 |
mktime(23,59,59,date(‘m’),date(‘d’)-date(‘w’)+7-7,date(‘Y’)) | 上周结束的时间戳 |
mktime(0,0,0,date(‘m’),1,date(‘Y’)) | 本月开始的时间戳 |
mktime(23,59,59,date(‘m’),date(‘t’),date(‘Y’)) | 本月结束的时间戳 |
ceil((date(‘n’))/3) | 当前季度 |
strtotime(“now”) | 等同于time() |
strtotime(“15 October 1980”) | 1980-10-15的时间戳 |
strtotime(“+5 hours”) | 当前时间5个小时后的时间戳 |
strtotime(“+1 week”) | 当前时间加一周的时间戳。即+7天 |
strtotime(“+1 week 3 days 7 hours 5 seconds”) | 当前时间加1周3天7小时5秒后的时间戳 |
strtotime(“next Monday”) | 下周一的时间戳 |
date(“Y-m-d h:i:s”,strtotime(“next Monday”)) | 显示下周一中午12点。eg:2017-05-22 12:00:00 |
strtotime(“last Sunday”) | 上周日的时间戳 |
date(“Y-m-d h:i:s”,strtotime(“last Sunday”)) | 上周日12:00 |
1 |
<span class="hljs-function"> </span> |
噢!评论已关闭。