I need to store the datetime in CST timezone regardless of any timezone given.
The Clients who access the application are from from various time zones, like IST, CST, EST,…
I need to store all the datetime entered by the client in CST timezone to my database. And while retrieving, i need to convert back to there local timezone.
How to achieve it?
It is generally accepted to store all datetime values in your DB in the GMT/UTC format.
For those who want to render the UTC value to a particular time zone for different users of the application, like wilpeck mentioned, it’s suggested that you determine the end users locale and:
EDIT:
For example:
You might have a table with a field StartDateTime so to support multiple time zones you might have an additional field StartDateTimeOffset. If the client is in the Indian Standard Time (IST) zone you might have a datetime value of 2009/10/13 14:45 which is 2009/10/13 09:15 in UTC. So you would store the UTC value (2009/10/13 09:15) in the field StartDateTime and store the offset +05:30 in the StartDateTimeOffset field. Now when you read this value back from the DB you can use the offset to convert the UTC datetime value (2009/10/13 09:15) back to the local time of 2009/10/13 14:45.