A Pen by Richard Leishman on CodePen.
Created
January 20, 2017 17:53
-
-
Save mrl22/61c6daf49fdd10bb59b2be39db3c6b2c to your computer and use it in GitHub Desktop.
Specific info at specific times of day EST timezone
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
| <div class="someclass"></div> |
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
| 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()); |
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 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