Sanibel Logic LLC

...Scalable Technologiesfor the Enterprise

Obtain Client Browser Time Zone

Sanibel Logic is offering a free download which may be useful for your software development.  ClientTime is an ASP.NET custom control based on an article entitled "Its About Time" in the January 2007 issue of ASP.NetPro magazine.  The ASP.NetPro article discusses the JavaScript requirements for obtaining the client browser time zone. I take the article a step further by encapsulating C# support methods and JavaScript injection code into the form of an ASP.NET custom control.  ClientTime can be useful for ASP.NET based web applications to ensure that all Date/Times are expressed in the client browser's time zone.

To illustrate, the following Administrative query which monitors ASP.NET Health Monitoring alerts shows all date and times (highlighted within red block) expressed in the local time zone of the client browser (the user).  In the case of Sanibel Logic, and with many corporations, this is significant because the user may be in one time zone, while the ASP.NET web server hosting provider may be in another time zone.  

 ClientTime2_2 Click image to enlarge...

CLICK HERE to review the online ClientTime class documentation.

CLICK HERE to download the ClientTime VS.NET 2008 source project.

To activate ClientTime, simply drop the ClientTime custom control onto the ASP.NET master page or content page, illustrated as follows:

   1:  </head>
   2:  <body>
   3:      <form id="form1" runat="server">
   5:      <asp:ScriptManager id="ScriptManager1" runat="server" AsyncPostBackTimeout="999">
   6:          <Scripts>
   7:              <asp:ScriptReference Path="~/Scripts/Ajax/ModalPopup.js" />
   8:              <asp:ScriptReference Path="~/Scripts/Ajax/ModalPopupConfirmation.js" />
   9:          </Scripts>
  10:      </asp:ScriptManager>
  12:      <slcms:ClientTime ID="cltClientTime" runat="server" />
  14:      <asp:HiddenField id="hflCurrentDiv" runat="server" /> 

The presence of the ClientTime custom control will cause the time zone related JavaScript to be injected.  To examine any of the ClientTime public properties or invoke any of the ClientTime methods simply reference the ClientTime custom control (or use FindControl if necessary).