Dealing with DateTime

R

rodchar

Hey all,
Let's say you have users across the country and the page displays a date and
time. how do you normally handle the timezone stuff? Should everyone see the
times according to their timezones? If so, how is this done?

thanks,
rodchar
 
R

RayLopez99

Hey all,
Let's say you have users across the country and the page displays a date and
time. how do you normally handle the timezone stuff? Should everyone see the
times according to their timezones? If so, how is this done?

thanks,
rodchar

Depends. DateTime is what most people use, which converts UTC into
local time automatically. However, hackers like to use
DateTimeOffset. Why? Because if you're doing a denial of service
attack, you want to have an "absolute" time, which DateTimeOffset
does. That's to say: DTO considers 6 pm EST the same as 3 pm PST the
same as 11 pm UTC, since they all equal 11 pm UTC. No explicit
conversion is necessary in DTO. But most programs I've seen, and I
personally, use DT only, for whatever reason, I guess convension.

RL
 
F

Family Tree Mike

rodchar said:
Hey all,
Let's say you have users across the country and the page displays a date and
time. how do you normally handle the timezone stuff? Should everyone see the
times according to their timezones? If so, how is this done?

thanks,
rodchar

If there are logins and user settings, you could capture the timezone as a
preference for each user. If you are just talking about timzones in a
relatively small area, then user's can probably interpret a standard such as
EST to PST.

To get the users timezone would require client side scripting and probably
just tell you that every user has their clock set incorrectly.

Mike
 
J

Jeff Johnson

Let's say you have users across the country and the page displays a date
and
time. how do you normally handle the timezone stuff? Should everyone see
the
times according to their timezones? If so, how is this done?

Since you said "page" I have to assume you're talking about a Web
application. In my experience, any time I've used a site that needs to
translate time to my local time, it has always asked my what my time zone
is. In other words, the Web app couldn't determine that on its own. I would
assume that dates are stored in its database in UTC and then the time offset
is added before they are displayed. From looking at various classes and
structures like DateTime and TimeZone, it doesn't appear that the .NET
framework (2.0 is what I use) has anything built-in to convert time from one
time zone to another, so you're pretty much stuck with physically adding a
time offest, like -5 or +1.5. As to where you find these offsets...I dunno.
You'd think the TimeZone class would have a static GetTimeZones() method
which would return the known time zones, but it doesn't.
 
R

rodchar

thanks all for the feedback, this helps.
rod.

Jeff Johnson said:
Since you said "page" I have to assume you're talking about a Web
application. In my experience, any time I've used a site that needs to
translate time to my local time, it has always asked my what my time zone
is. In other words, the Web app couldn't determine that on its own. I would
assume that dates are stored in its database in UTC and then the time offset
is added before they are displayed. From looking at various classes and
structures like DateTime and TimeZone, it doesn't appear that the .NET
framework (2.0 is what I use) has anything built-in to convert time from one
time zone to another, so you're pretty much stuck with physically adding a
time offest, like -5 or +1.5. As to where you find these offsets...I dunno.
You'd think the TimeZone class would have a static GetTimeZones() method
which would return the known time zones, but it doesn't.
 

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