We are having a sale on our website on Black Friday. And we want to run it globally on that day. I think the following solution works in checking for the correct time but having compared my solution to https://www.timeanddate.com/ it's giving me conflicting results for 'Pacific/Midway', I'm sure this should be the next day, Sat 24.
Thoughts welcome on improvements to this code/approach also.
$start = Carbon::create(2018, 11, 23, 0, 0, 0, 'Pacific/Kiritimati');
$end = Carbon::create(2018, 11, 23, 23, 59, 59, 'Pacific/Midway');
$now = Carbon::now();
if ($start < $now && $end > $now) {
// Is black Friday
}
via Chebli Mohamed

Aucun commentaire:
Enregistrer un commentaire