Click here to Skip to main content
12,399,640 members (51,139 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
how can i display current date and time in my application as per respected time zones.
For example, if i open my app in INDIA,it should show indian current time.same in other time zones. My application is now displaying US time because the application hosted in USA servers.Please help me out. Thanx in Advance
Posted 23-Jan-13 2:26am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I am assuming that you are asking about a web-based application.

Use of the JavaScript Date Object may solve your issue. You can write some JavaScript code that runs on the client PC to compute the local time from the GMT.

// Generate the following JavaScript line on the server
// inserting the GMT date and time.
// In this example: GMT = 23 January 2013 16:15
var theDate = new Date(2013,01,23,16,15,0,0); 
 
// The above line creates the Date object.
// The following line converts the Date object to a local time zone string.
var myLocalDate = theDate.toLocaleString();

Note: I have not tested this solution. I just read my JavaScript manual to learn about the Date object and compose my suggested solution.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100