I'm trying to write a JavaScript code that will display a certain message between two hours in a day. We're in eastern standard time but I have no problem working with universal time, because that makes writing the script much easier. So far, I have this and it works great, however, I'm completely stumped with regards to working with daylight savings time.
$(document).ready(function(){
var todaysDate = new Date();
var weekday = todaysDate.getDay();
var universalhour = todaysDate.getUTCHours();
if (weekday >= 0) {
if (weekday <= 4) {
if (universalhour >= 14) {
if (universalhour < 23) {
$('div#announcements span').append('<br />Open.');
}
}
}
}
if (weekday == 5) {
if (universalhour >= 14) {
if (universalhour < 20) {
$('div#announcements span').append('<br />Open.');
}
}
}
});
Basically, the message "Open" should only display between 10am EST and 8pm EST, Sunday-Thursday and 10am EST to 4pm EST Friday.
I have no problem working with UST, I just need help figuring out a workaround for Daylight Savings Time, as this i sbeyond my field of knowledge.