<?php
$currentDateTime = new DateTime("now", new DateTimeZone("Europe/Kiev"));
if(isWeekend($currentDateTime)){
_e( "Сообщение в выходной", 'woocommerce' );
}else{
if (isBeforeAM($currentDateTime)) {
_e( "Сообщение до обеда", 'woocommerce' );
}else{
_e( "Сообщение после обеда", 'woocommerce' );
}
}
function isWeekend($currentDateTime) {
if (isFridayWeekend($currentDateTime)) {
return true;
}
return $currentDateTime->format('N') >= 6;
}
function isBeforeAM($currentDateTime){
$currentTimeStamp = $currentDateTime->getTimestamp();
$timeStamp = strtotime(date('Y-m-d') . "13:00");
return $currentTimeStamp < $timeStamp ;
}
function isFridayWeekend($currentDateTime){
return $currentDateTime->format('N') == 5 && isBeforeAM($currentDateTime);
}
?>
Отправка сообщений происходит не корректно, отправляет не то что должно в будние дни