Save Datetime Issue With Users Local Datetime
Solution 1:
If the timestamp is stored as Coordinated Universal Time (UTC), then all you should have to is format the value from the database according to the user's local timezone.
For example, assuming that the timestamp from the database is in milliseconds (e.g. 1309365893296), then in javascript, you can do the following to convert it to the user's local timezone:
var localtime = newDate(1309365893296);
Solution 2:
I'd guess the best way would be to collect a DateTime value from your user's PC whenever they submit text.
From that, you should be able to determine what time zone they are in based on the number of hours difference.
Then, whenever you display the time stamp in your application, add or subtract the number of hours difference.
Solution 3:
What you need to do is store all of your timestamps using DateTime.UtcNow
When you go to display the time to the user, you can use .ToLocalTime()
off of your variable to convert it to each users' local timezone.
Post a Comment for "Save Datetime Issue With Users Local Datetime"