php时间格式的转换函数有date(),strtotime()函数,php 原生的时间类也能够转换时间格式。php
一、Y-m-d转换为时间戳 例:2017-08-22 转化为时间戳 strtotime(‘2017-08-22’);yii
二、时间戳转换为Y-m-d H:i:s date("Y-m-d H:i:s",strtotime('2017-08-22'));curl
三、时间Ymd格式转化为Y-m-d date(“Y-m-d”,strtotime("20170822"));函数
用原生php类也能够直接转换 var_dum(\DateTime::createFromFormat('Ymd','20170822')->format('Y-m-d'));post
四、获取当前时间戳:一、time(); 二、date('U');this
五、明天的时间格式 date("Y-m-d H:i:s",strtotime(+1 day));url
获取一段时间的日期 搜过来的代码orm
$end = new \DateTime($end);$end = $end->modify( '+1 day' );$interval = new \DateInterval('P1D');// yii中引用原生的php类加\,由于有命名空间$daterange = new \DatePeriod($start, $interval ,$end);//查询这个时间段内全部的日期foreach($daterange as $date){ $single_date = $date->format("Ymd");//每一个日期都改为20170022的格式 $this->run_curl($url,$post_data,$project,$flow,$single_date,$timeBegin,$timeEnd);}$datarange就是时间段内的日期。