Hide content after 9AM in different time zones - VBScript

I would like to hide some content on my web page after 9AM. This is how I'm doing it now:

<%If FormatDateTime(Time, vbShortTime) < "09:00" Then %>
SHOW CONTENT
<%else%>
DON’T SHOW CONTENT
<%end if%>

The problem is that there are cities that are not in my time zone, and I'd like to hide the content when it's 9AM where they are. My city is ORD which is in central time. The other cities are EWR + 1hour, DEN -1hour, SFO -2hours. How could I hide the content at 9AM in each city?
Thank you for your help.
romsomAsked:
Who is Participating?
 
Big MontyConnect With a Mentor Senior Web Developer / CEO of ExchangeTree.org Commented:
you don't HAVE to use jquery, I just used it as an example. using the example code above, i think we can do the following:

<html> 
  <head> 
    <title>Untitled Document</title> 
    <script type="text/javascript"> 
function test() {
   var localTime = new Date();

   if ( localTime.getHours() <= 9 ) 
      document.getElementById('deletesuccess').style.display = 'none';

}
    </script>
  </head> 
  <body onload="test();"> 
    <div id=deletesuccess > hiiiiiiiiiii </div> 
  </body> 
</html>

Open in new window

0
 
Don ThomsonCommented:
This code will allow you to figure out the TimeZone.

However - If you are hiding a folder or file on a ORD server - I don't see how you could do it - Either the file/Folder is seen or is hidden once you run the actual vbs.

http://blogs.technet.com/b/heyscriptingguy/archive/2007/11/27/hey-scripting-guy-how-can-i-retrieve-time-zone-information-for-a-computer.aspx
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
2 ways you could approach this depending on your setup:

if you have users logging into the site, then you could add timezone and timezone offset columns to your users table and do a calculation based off of that data. This would obviously need the user to enter in their time zone location :)

if you have a open site, meaning users don't have to log in, then you would need to use javascript to get the users local time.

<script>
$(document).ready(function () {      //-- page onload constructor if using jquery

var localTime = new Date();

if ( localTime.getHours() >= 9 )
      //-- show content
else
      //-- hide content
}
</script>
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
romsomAuthor Commented:
What I would like to hide is a form. Users are not supposed to submit it after 9AM.

I was thinking of a multidimensional array, something like this, but I can't make it work in VBScript:

Var TimeArray: Array = ( [“EWR”,1,], ( [“ORD”,0,], ( [“DEN”,-1,], ( [“SFO”,-2,]   )
Get index of my City ie: EWR
If (index= -1) then{ Reatime = Now()} else <- this prevent errors in case the user’s city is not on the list.
{  
Array Index of EWR =  0
timeDifference = TimeArray[0][1]
timeDifference = 1

RealTime = AddDate(‘h’, timeDifference , Now() )
}
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
after the server 9am or the users 9am?
0
 
romsomAuthor Commented:
I'd like to hide the content after the user's 9AM
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
then you don't need to worry about what the server time is, you just need to get the users local time. Try my 2nd solution above and see if that doesn't work for you
0
 
romsomAuthor Commented:
What jquery do I have to use? I found something similar, but this example times out instead of becoming invisible after a certain time of the day:

<html>
  <head>
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
      $(document).ready( function() {
        $('#deletesuccess').delay(1000).fadeOut();
      });
    </script>
  </head>
  <body>
    <div id=deletesuccess > hiiiiiiiiiii </div>
  </body>
</html>
0
 
romsomAuthor Commented:
This seems to be working, thank you very much. But how could I make the content invisible after e.g. 9:15 AM?
<=9:15 doesn't work
0
 
romsomAuthor Commented:
Thank you very much.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
thanks for the points :)

to answer your question, you would need to use getMinutes() on the time. so change the if statement to:

if ( localTime.getHours() <= 9 && localTime.getMinutes() >= 15 )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.