Last active
May 2, 2019 02:27
-
-
Save robhob/9b8e0e3c114a31a80082af3f0fc49b5f to your computer and use it in GitHub Desktop.
This function was written to work with the free "Content Visibility for Divi Builder" plugin (https://wordpress.org/plugins/content-visibility-for-divi-builder/). Add the following line to the Content Visibility field of the chosen Section or Module: is_daytime();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_daytime() { | |
$time_now = date("H:i a"); | |
$time_now = DateTime::createFromFormat('H:i a', $time_now); | |
$morning = "7:00 am"; | |
$morning = DateTime::createFromFormat('H:i a', $morning); | |
$evening = "8:00 pm"; | |
$evening = DateTime::createFromFormat('H:i a', $evening); | |
if ($time_now >= $morning && date("h:i") <= $evening) | |
{ | |
return 1; | |
} | |
else { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this. Will this show the module between 7:00 AM and 8:00 PM, and hide the module from 8:00 PM to 7:00 AM?