Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,908
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by mackm View Post
    Well I set up a few tables on a daily schedule like the example you gave, so that a new table appears every day. The tables actually consist of drink specials and since most pubs and bars run well into the morning of the next day, I would like to have the specials switch at 6 am, rather than 12 am. (6 hours)

    Thank you for all your help!
    Code:
    var scheduleDays = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
    onload = function() {
      var today = new Date();
      var DOW = today.getDay();
      var hr = today.getHours();
      if (hr < 6 ) {
      DOW --;
      if (DOW == -1) {DOW = 6}
    }
    
    document.getElementById(scheduleDays[DOW]).style.display = 'block';
    }

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  2. #17
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,073
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    If I am understanding the requirement correctly
    it should only take a 2 line addition...
    Code:
    onload = function() {
      var today = new Date();
      var DOW = today.getDay();
      var hh = today.getHours();
      if (hh < 6) { DOW--;  if (DOW < 0) { DOW = scheduleDays.length-1; } }
      document.getElementById(scheduleDays[DOW]).style.display = 'block';
    }
    Last edited by jmrker; 04-17-2012 at 03:20 PM. Reason: Dang that 'Philip M'. He must rise at dawn!!!

  3. #18
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what determines the time zone?

  4. #19
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,908
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by prophecyprojekt View Post
    what determines the time zone?
    The time as per the user's computer.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  5. #20
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,073
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    Quote Originally Posted by prophecyprojekt View Post
    what determines the time zone?
    You could evalutate using getUTCtime() and then adjust for the time zone of the user,
    but that is more complicated than just using getTime() and it probably depends upon
    the user setting his/her computer clock correctly anyway.

    See: http://www.w3schools.com/jsref/jsref_obj_date.asp


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •