Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chris-castillo-dev/69daecd6838f27e16996a50450085046 to your computer and use it in GitHub Desktop.
Save chris-castillo-dev/69daecd6838f27e16996a50450085046 to your computer and use it in GitHub Desktop.
<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