生成按照天数初始化的随机九位唯一自增字符串
//获取本月起始时间戳和结束时间戳
public static function month_start_end(){
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'));
$date_data['start'] = $beginThismonth;
$date_data['end'] = $endThismonth;
return $date_data;
}
//生成随机字符串,位数九位
public function CkServiceId($lastnum){
$date_data = ArrayHelper::month_start_end();
$time = time();
if ($time <= $date_data['end'] && $time >= $date_data['start']){
$ckserviceid = date('ymd') . sprintf('%03d',$lastnum+1);
}else{
$ckserviceid = date('ymd') . sprintf('%03d',1);
}
return $ckserviceid;
}
本作品采用《CC 协议》,转载必须注明作者和本文链接