建站资讯
帝国cms通过火车头采集器/高铁采集器发布文章设置随机时间
简介:$timen= rand(18,20);
$timey= rand(1,9); $timer= rand(1,29); $timeh= rand(7,22);
$timem= rand(0,59);
$times= rand(0,59);
if($timey
$timen= rand(18,20);
$timey= rand(1,9);
$timer= rand(1,29);
$timeh= rand(7,22);
$timem= rand(0,59);
$times= rand(0,59);
if($timey<10){
$timey="0".$timey;
}
if($timer<10){
$timer="0".$timer;
}
if($timeh<10){
$timeh="0".$timeh;
}
if($timem<10){
$timem="0".$timem;
}
if($times<10){
$times="0".$times;
}
$times="20$timen-".$timey."-".$timer." ".$timeh.":".$timem.":".$times;
$ntimeh=(int)date('H',time())-rand(1,3);
以上代码放在帝国cms火车头免登录发布接口文件中即可
代码解释:
生成一个随机的日期时间,并将生成的日期时间赋值给$_POST['newstime']变量。具体实现如下:
rand()函数生成随机的小时(18-20)、年份(1-9)、日期(1-29)、小时(7-22)、分钟(0-59)和秒钟(0-59)。20年份-日期-小时:分钟:秒钟的形式,例如2023-12-11 15:25:08。当前年份-当前日期-新小时:分钟:秒钟的形式。$_POST['newstime']变量。下一个:微信关联小程序的意义