Date.Now

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
 
S

Scott M.

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
 
M

Miro

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
 
A

Andrew Morton

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
 
M

Miro

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
 
M

Miro

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

:)

M.
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top