21,886
社区成员
发帖
与我相关
我的任务
分享
$h = date('H', time());
$i = date('i', time());
$s = date('s', time());
if(!isset($_COOKIE['d']) || $_COOKIE['d'] != date('d', time())){//如果不存在标识变量(今天的号)或者号不一样,那么从1开始
setcookie('d', date('d'), time() - $h * 3600 - $i * 60 - $s + 24 * 3600);
setcookie('count', 1, time() - $h * 3600 - $i * 60 - $s + 24 * 3600);
$count = 1;
}else{
$count = $_COOKIE['count'];
}
$l = strlen($count);
switch($l){
case 1:
$s = '000';
break;
case 2:
$s = '00';
break;
case 3:
$s = '0';
break;
default:
break;
}
$s .= $count++;
setcookie('count', $count, time() - $h * 3600 - $i * 60 - $s + 24 * 3600);
echo date('Ymd', time()).$s;