ali 2017-05-19 12:17:02 4257次浏览 0条评论 3 2 0
public function actionCalculatedays($staffCode)
{
   $monthStart=substr(date("Y-m-d",mktime(0, 0 , 0,date("m"),1,date("Y"))),9,1);
   $monthEnd=substr(date("Y-m-d",mktime(23,59,59,date("m"),date("t"),date("Y"))),8,3);
    $count=0;
   $result=($monthEnd-$monthStart)+1;
    $days=$result;
    $start_day=date("Y-m-d",mktime(0, 0 , 0,date("m"),1,date("Y")));
    for($i=0;$i<$days;$i++)
    {
       if (Staffstatic::find()->where(['and',
           ['>=','createTime',date('Y-m-d 00:00:00',strtotime($start_day)+$i*24*60*60)],
           ['<=','createTime',date('Y-m-d 23:59:59',strtotime($start_day)+$i*24*60*60)],
           ['staffCode'=>$staffCode]
       ])->asArray()->one()){
           $count++;
       }
    }
    return $count;
}
觉得很赞
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册