Globalization and time difference / zone

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hi,

Users can add news items on my website. Each news item have a create
date and time.
Now I want that users see the correct time in there zone.
(9 PM at location x can me 11 PM at location y).

How should I save my datatime in the database?
And how do I show the correct datetime for a specific user/culture?

Thanks!
 
Edit:
(9 PM at location x can me 11 PM at location y).
can me --> could be

I also don't understand the UtcNow.
In my Windows I have timezone +1 when I show the time with C# then I
see -2.
I don't understand this.

Second, I cannot find a function to long datetime. There is a longdate
and longtime, but not one combined???

Thanks!
 
How should I save my datatime in the database?
And how do I show the correct datetime for a specific user/culture?

You only UTC time in your database.

1. Get time in UTC
2. Find the offset of the TimeZone from UTC
3. Add the offset (TimeSpan) to the time in UTC
4. Display the new time... :-)
 
Back
Top