Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var dayOfWeek = now.getDay();
  2. //weekday 0==Sunday 1==Monday 2==Tuesday 3==Wednesday 4==Thurs 5==Friday 6==Sat
  3. //Not Friday or Saturday
  4. if ((dayOfWeek != 5) && (dayOfWeek != 6)){
  5.  
  6. if (now.getHours() >= 9 && now.getHours() < 17 ) {
  7. //Within working hours now."
  8. }
  9. else
  10. {
  11. //After working hours."
  12. }
  13. }
  14.  
  15. }
  16.  
  17. function isWorkingHour(now) {
  18. return now.getDay() <= 4 && now.getHours() >= 9 && now.getHours() < 17;
  19. }
  20.  
  21. function checkOpeningTimes() {
  22. let date = new Date(); // current time
  23. let hours = date.getHours();
  24. let day = date.getDay();
  25. let openingDays = [ 0, 1, 2, 3, 4 ];
  26. return openingDays.includes( day ) && hours >= 9 && hours <= 17;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement