🌐
经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用
点我优惠购买
🚀
拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多
点我优惠购买
🛡️
稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少
点我优惠购买
温馨提示:这篇文章已超过529天没有更新,请注意相关的内容是否还可用!
PHP获取时区
1 2 | date_default_timezone_set( 'PRC' ); //这两种方法效果相同 |
时间戳转日期,可以用date(‘Y-m-s h:i:s’, 具体时间戳来实现)
日期转换时间戳,用strtotime("date()").
php获取时间戳
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //获取今日开始时间戳和结束时间戳 $beginToday = mktime (0,0,0, date ( 'm' ), date ( 'd' ), date ( 'Y' )); $endToday = mktime (0,0,0, date ( 'm' ), date ( 'd' )+1, date ( 'Y' ))-1; //获取昨日起始时间戳和结束时间戳 $beginYesterday = mktime (0,0,0, date ( 'm' ), date ( 'd' )-1, date ( 'Y' )); $endYesterday = mktime (0,0,0, date ( 'm' ), date ( 'd' ), date ( 'Y' ))-1; //获取本周起始时间戳和结束时间戳 $beginThisweek = mktime (0,0,0, date ( 'm' ), date ( 'd' )- date ( 'w' )+1, date ( 'y' )); $endThisweek =time(); //获取上周起始时间戳和结束时间戳 $beginLastweek = mktime (0,0,0, date ( 'm' ), date ( 'd' )- date ( 'w' )+1-7, date ( 'Y' )); //获取本月起始时间戳和结束时间戳 $beginThismonth = mktime (0,0,0, date ( 'm' ),1, date ( 'Y' )); $endThismonth = mktime (23,59,59, date ( 'm' ), date ( 't' ), date ( 'Y' )); //上个月的起始时间: $begin_time = strtotime ( date ( 'Y-m-01 00:00:00' , strtotime ( '-1 month' ))); $end_time = strtotime ( date ( "Y-m-d 23:59:59" , strtotime (- date ( 'd' ). 'day' ))); $begin_year = strtotime ( date ( "Y" ,time()). "-1" . "-1" ); //本年开始 $end_year = strtotime ( date ( "Y" ,time()). "-12" . "-31" ); //本年结束 //现在的时间到第二天凌晨相差的时间戳 $time = ( strtotime ( date ( 'Y-m-d' ))+3600*24) - time() ; |
php获取日期
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | echo '<br>上周起始时间:<br>' ; echo date ( "Y-m-d H:i:s" , mktime (0, 0 , 0, date ( "m" ), date ( "d" )- date ( "w" )+1-7, date ( "Y" ))), "\n" ; echo date ( "Y-m-d H:i:s" , mktime (23,59,59, date ( "m" ), date ( "d" )- date ( "w" )+7-7, date ( "Y" ))), "\n" ; echo '<br>本周起始时间:<br>' ; echo date ( "Y-m-d H:i:s" , mktime (0, 0 , 0, date ( "m" ), date ( "d" )- date ( "w" )+1, date ( "Y" ))), "\n" ; echo date ( "Y-m-d H:i:s" , mktime (23,59,59, date ( "m" ), date ( "d" )- date ( "w" )+7, date ( "Y" ))), "\n" ; echo '<br>上月起始时间:<br>' ; echo date ( "Y-m-d H:i:s" , mktime (0, 0 , 0, date ( "m" )-1,1, date ( "Y" ))), "\n" ; echo date ( "Y-m-d H:i:s" , mktime (23,59,59, date ( "m" ) ,0, date ( "Y" ))), "\n" ; echo '<br>本月起始时间:<br>' ; echo date ( "Y-m-d H:i:s" , mktime (0, 0 , 0, date ( "m" ),1, date ( "Y" ))), "\n" ; echo date ( "Y-m-d H:i:s" , mktime (23,59,59, date ( "m" ), date ( "t" ), date ( "Y" ))), "\n" ; //本年起始 echo date (‘Y-01-01’); //结束日期 echo date (‘Y-12-31’); |
文章版权声明:除非注明,否则均为执刀人的工具库原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...