Click here to Skip to main content
11,578,739 members (63,155 online)
Rate this: bad
good
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
0 Peter Leow 135
1 Frankie-C 115
2 OriginalGriff 113
3 Richard MacCutchan 85
4 Afzaal Ahmad Zeeshan 75
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 403


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2015
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