Skip to content

Instantly share code, notes, and snippets.

@mrl22
Created January 20, 2017 17:53
Show Gist options
  • Select an option

  • Save mrl22/61c6daf49fdd10bb59b2be39db3c6b2c to your computer and use it in GitHub Desktop.

Select an option

Save mrl22/61c6daf49fdd10bb59b2be39db3c6b2c to your computer and use it in GitHub Desktop.
Specific info at specific times of day EST timezone
<div class="someclass"></div>
function myFunction() {
var dt = new Date();
dt.setTime(dt.getTime()+dt.getTimezoneOffset()*60*1000);
var estOffset = -300; //Timezone offset for EST in minutes.
var now = new Date(dt.getTime() + estOffset*60*1000);
var day = now.getDay();
var hour = now.getHours();
if (hour < 8) {
if (day >= 1 && day <= 5) {
return "Get a Quote By 11am (EST)";
} else if (day == 0 || day == 6) {
return "Get A Quote By 11am (EST) Monday";
}
} else if (hour > 16) {
if (day >= 1 && day <= 4) {
return "Get Quote By 11am (EST) Tomorrow";
} else if (day == 0 || day == 5 || day == 6) {
return "Get A Quote By 11am (EST) Monday";
}
} else {
if (day >= 1 && day <= 4) {
return "Get A Quote Within 3 Hours";
} else if (day == 5) {
return "Get A Quote Within 3 Hours";
} else if (day == 0 || day == 6) {
return "Get A Quote By 11am (EST) Monday";
}
}
}
$('.someclass').html(myFunction());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment