0

what I'm trying to achieve here is as follows:

Javascript gets the current server time and converts it to eastern time following which the script checks if the time falls within a few time range and if so, display an asp.net button in the page.

Time ranges are like so: 08:45 - 09:00, 09:00 - 10:00, 10:00 -10:45 etc.

So the script will loop through the time ranges and if it falls within the specified range, the button will be visible.

Really need help on this. Appreciate it. Thanks!

Nick
  • 1
  • 3
  • See http://stackoverflow.com/questions/6212305/how-can-i-compare-two-time-strings-in-the-format-hhmmss, then create a function which takes 3 times and determines if the first parameter is between the other 2 (> than 2nd and < than the third). Then set your flag false and loop over each item with flag = flag || your new function(server time in eastern, timeRanges[i][0], timeRanges[i][1]) – Jeremy Kahan Sep 23 '16 at 04:32
  • *"and converts it to eastern time"* - Why Eastern time specifically? If you want to control display of a button based on one specific timezone regardless of where the user is then you should do it server side. I wouldn't try to do it in client-side code unless applying the user's timezone. – nnnnnn Sep 23 '16 at 04:38

1 Answers1

0

Take a look to http://momentjs.com/ is all you need to work with dates and times also http://momentjs.com/timezone/ for conversions between time zones

Zeze Lazo
  • 45
  • 1
  • 5