Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hai to all,
my question is i want store different countries times based on their local time. actually my server in dullas. then it shows and stores dullas time. how to change or store country wide timings.

ex: in india it shows and stores india time, in usa it shows and stores usa time
Posted
Comments
joshrduncan2012 12-Dec-12 12:52pm    
Database?

At least when I deal with this all the time used in Web Application is the time machine using this site, regardless of the time that this server.
But you may need to configure Global.asax.vb (or just Global.asax)
With the following line:

VB
Public nfi2 As CultureInfo = CultureInfo.InvariantCulture


And when using the data, you can use the value of local culture machine.
example:

VB
Date.ParseExact(TextBoxDate.Text.Trim(), "d/M/yyyy", nfi2)
 
Share this answer
 
Always store DateTime.UtcNow rather than DateTime.Now. So that you will get a Universal Time irrespective of the location.

Read this for more details about UTC.
http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime(v=vs.100).aspx[^]

While retrieving/displaying, calculate Local time using CurrentTimeZone and UtcOffset to get the actual time based on the location.

Read this for more details about UTC Offset.
http://msdn.microsoft.com/en-us/library/system.timezone.getutcoffset(v=vs.100).aspx[^]
 
Share this answer
 
v2

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