Globalization and time difference / zone

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!
 
A

Arjen

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!
 
G

Gaurav Vaish \(www.EduJini.IN\)

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... :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top