I've got a database that holds a period as UTC. This time around could be proven inside a web page, so I’ve been requested to exhibit it as being local amount of time in the page as possible seen from the country. A friend pointed out something about obtaining the country configurations in the current thread (around the server) however i couldn’t find any particulars about this. Is exactly what I wish to do possible?

Should you (as well as your website) are comfy with javascript, there's an easy way to do this.

First, around the server side, you'd possess the UTC date/time formatted in RFC 3339 format (the conventional for internet time utilized by, among other methods, icalendar). The fundamental syntax of RFC 3339 is:


So that where I'm, time could be:


However when time isn't local, but UTC, you give a Z towards the finish to denote this. So during my situation, since I am at -0500 hrs from GMT, the same time frame above could be:


So, firstly you obtain the server to output the above mentioned for your web page's javascript. The javascript may then parse that timestamp and it'll output the time and date modified towards the browser's time zone (which is dependent upon the pc hosting the browser). You should never forget when a person comes from Tokyo, japan and it is viewing your site in The country, they'll begin to see the timestamp in Tokyo, japan time unless of course they have modified their computer's clock.

Therefore the javascript could be:

    var time_string_utc = some_server_variable; // timestamp from server
    var time_string_utc_epoch = Date.parse(some_server_variable);
    var time_utc = new Date();

At this time, you've got a javascript date object set for your UTC timestamp. A fast explanation of the items happens above:

The very first variable assumes you've passed the timestamp string to that particular variable in the server.

The 2nd variable uses the Date.parse() approach to convert the string for an epoch timestamp.

The 3rd variable produces the unset Date object.

The final line line uses setTime method, which sets to start dating ? object from an epoch timestamp.

Now that you've got the item, you are able to output it towards the user as you can see fit. Like a simple experiment, you should use:


which, if you're during my timezone while using UTC timestamp I began served by:



 Tue May 04 2010 05:52:33 GMT-0500 (CST)

but you should use various javascript techniques to format time into something a lot more enjoyable searching.

You don't need to guess anyone's country as well as adjust your timestamp, as long as you trust anyone's local browser/computer time zone.

Again, rapid version:

    var time_string_utc = some_server_variable; // UTC time from server
    var time_string_utc_epoch = Date.parse(some_server_variable);
    var time_utc = new Date();

Of-course can be done. You need to simply discover that country settings to identify the nation your user originates from, after which customize the displayed date to suit that country's time.There are also a different way to identify the consumer country.(maybe from his ip).

I am certain that the easiest method to manage this really is give your friend know that you'll require more particulars concerning the country configurations implementation in your project and just how do you need it.


Considering it I do not think you'll be able to display the neighborhood time after you have the client’s culture. I'd easily be interested to visit your co-workers suggestion.

Obtaining the US culture, for instance, will not help because the US has numerous timezones.

I believe using Javascript like Anthony indicates could be what you want...


You are able to override the InitializeCulture() method with code that sets the present (selected or browser confirming) cultures:

Thread.CurrentThread.CurrentCulture = 
Thread.CurrentThread.CurrentUICulture = new