php
比如,今天是2102年11月2号,那么php要获取2102年11月2号的时间戳是怎么办的呢?
代码:echostrtotime(date('y-m-d')),'
';
获取明天凌晨的时间戳
代码:echostrtotime(date('y-m-d',strtotime('+1 day'))),'
';
附上测试代码:
echo strtotime('2012-11-2'),'
';
echo strtotime('2012-11-2 00:00:00'),'
';
echo strtotime(date('y-m-d')),'
';
echo date('y-m-d h:i:s',strtotime(date('y-m-d'))),'
';
echo strtotime(date('y-m-d',strtotime('+1 day'))),'
';
echo ( strtotime(date('y-m-d',strtotime('+1 day'))) -strtotime(date('y-m-d')) )/3600;
date_default_timezone_set('prc'); //默认时区 echo今天:,date(y-m-d,time()),
; echo今天:,date(y-m-d,strtotime(18 june 2008)),
; echo昨天:,date(y-m-d,strtotime(-1 day)),
; echo明天:,date(y-m-d,strtotime(+1 day)),
; echo一周后:,date(y-m-d,strtotime(+1 week)),
; echo一周零两天四小时两秒后:,date(y-m-d g:h:s,strtotime(+1 week 2 days 4 hours 2 seconds)),
; echo下个星期四:,date(y-m-d,strtotime(next thursday)),
; echo上个周一:.date(y-m-d,strtotime(last monday)).
; echo一个月前:.date(y-m-d,strtotime(last month)).
; echo一个月后:.date(y-m-d,strtotime(+1 month)).
; echo十年后:.date(y-m-d,strtotime(+10 year)).
;
以上就介绍了 php 获取昨天 今天 明天的时间,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。