Click here to Skip to main content
15,919,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900