Answer the question
In order to leave comments, you need to log in
I can not understand where I made a mistake in DateTime?
<?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);
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question