Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Date.Now

Reply
Thread Tools

Date.Now

 
 
Miro
Guest
Posts: n/a
 
      01-25-2010
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

 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      01-25-2010
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

"Miro" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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



 
Reply With Quote
 
 
 
 
Miro
Guest
Posts: n/a
 
      01-26-2010
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


"Scott M." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> "Miro" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>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

>
>


 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      01-26-2010
Miro wrote:
> 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


 
Reply With Quote
 
Miro
Guest
Posts: n/a
 
      01-26-2010
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




"Andrew Morton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Miro wrote:
>> 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
>


 
Reply With Quote
 
Miro
Guest
Posts: n/a
 
      01-27-2010
With all that being said,
my original calculation was AddHours(-3)
and with the clock in california - it should have been +3



M.

"Miro" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>
>
> "Andrew Morton" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Miro wrote:
>>> 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
>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments