我想找出不同时区的2次之间的差异。
我可以使用存储在我们数据库中的2次字符串,并根据设置的时区和2次($timeFrom
& $timeTo
)运行cron作业。
$timezone = $timezone // like (UTC)
$timeFrom = $timeFrom // like 09:00:00
$timeTo = $timeTo // like 01:00:00
date_default_timezone_set($timezone);
$currentTime = Carbon::now();
$timeFrom = Carbon::parse($timeFrom)->minute(0)->second(0);
$dateExplode = explode(':',$timeTo);
$checkDate = ltrim($dateExplode[0],'0');
if($checkDate > 0 && $checkDate < 12){
$timeTo = Carbon::parse($timeTo)->minute(0)->second(0)->addDay();
} else {
$timeTo = Carbon::parse($timeTo)->minute(0)->second(0);
}
$check = $currentTime->between($timeFrom,$timeTo); // result TRUE/FALSE
当我使用between
运行cron用户时区时。我错过了什么?