Last active
January 16, 2022 19:14
-
-
Save chris-castillo-dev/69daecd6838f27e16996a50450085046 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<script> | |
var time = new Date(); | |
var dayOfWeek = time.getDay(); | |
// Set office opening time to 8:15am | |
var startTime = new Date().setHours(8,15); | |
// Set office closing time to 4:15pm | |
var endTime = new Date().setHours(16,15); | |
// Check if its a business day | |
if( dayOfWeek == 1 | dayOfWeek == 2 | dayOfWeek == 4 | dayOfWeek == 5 ){ | |
// If Friday, set close time to 12:15pm | |
if( dayOfWeek == 5 ){ | |
endTime = new Date().setHours(12, 15); | |
} | |
// Check if within business hours | |
if (time.getTime() < startTime || time.getTime() > endTime) { | |
// console.log('Not inside business hours ... calls not allowed'); | |
$('.js-call-element').remove(); | |
} | |
}else{ | |
// Not a day of business | |
// console.log('Not inside business hours ... calls not allowed'); | |
$('.js-call-element').remove(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment