Date.Now

  • Thread starter Thread starter Miro
  • Start date Start date
M

Miro

I was wondering if there is a web.config setting that allows me to specify a
calculation for a date.

Basically the server I am using is in california but I want the time to
always reflect the EST ( toronto/new york ) time whenever in my vb.code I
have dim mydate as date = date.now

Currently I just always subtract 3 hours from the date.now but I would like
an "automatic solution" if there is one.

Thanks,

Miro
 
You could create an application setting (which gets stored in web.config)
and have that setting get set to now - 3 in global.asax/appliation_start, so
that whenever you need to get the EST, you just extract the application
setting value.

-Scott
 
Yeah that is similar to what I do now.

Except I just hardcoded a function to return .AddHours(-3)

I know I would have to - recompile if the server moved...but since I am in
charge of the hosting account as to where the web page is being hosted, then
I just popped it into a "class" with a couple hard coded parameters.

Thanks,

Miro
 
Miro said:
Yeah that is similar to what I do now.

Except I just hardcoded a function to return .AddHours(-3)

I know I would have to - recompile if the server moved...but since I
am in charge of the hosting account as to where the web page is being
hosted, then I just popped it into a "class" with a couple hard coded
parameters.

Could it be that daylight saving time will come in to operation on different
dates between California and Toronto/New York? If so, you might be better
off calculating the offset from DateTime.UtcNow instead of .Now. Then it
would not matter if the server was moved (or if California moved).

Andrew
 
hmmm I never thought of that.

I basically use it for an email that is sent out in html format with a "date
/ time submitted " on it for a booking system.

But I think you are correct. The clock will be 1 hour off for about 3 hours
when the clocks shift.
I will put in the UTC.now cause otherwise I know that the above issue would
bug me every time the clock shifts forward and backwards.

Personally I think they should just shift ALL the clocks by 30 minutes and
just let it be for the whole year.
Saskatchewan does it right - they dont shift at all.

Thanks

Miro
 
With all that being said,
my original calculation was AddHours(-3)
and with the clock in california - it should have been +3

:-)

M.
 
Back
Top