Date.Now

Discussion in 'ASP .Net' started by Miro, Jan 25, 2010.

  1. Miro

    Miro Guest

    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
    Miro, Jan 25, 2010
    #1
    1. Advertising

  2. Miro

    Scott M. Guest

    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" <> wrote in message
    news:%...
    >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
    Scott M., Jan 25, 2010
    #2
    1. Advertising

  3. Miro

    Miro Guest

    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." <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:%...
    >>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

    >
    >
    Miro, Jan 26, 2010
    #3
  4. 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
    Andrew Morton, Jan 26, 2010
    #4
  5. Miro

    Miro Guest

    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" <> wrote in message
    news:...
    > 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
    >
    Miro, Jan 26, 2010
    #5
  6. Miro

    Miro Guest

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

    :)

    M.

    "Miro" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> 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
    >>

    >
    Miro, Jan 27, 2010
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    589
    Matthew Speed
    Nov 8, 2003
  2. =?Utf-8?B?UmV6YQ==?=
    Replies:
    1
    Views:
    2,933
    Raterus
    Feb 27, 2004
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,229
    Michael Borgwardt
    May 30, 2004
  4. Matt
    Replies:
    2
    Views:
    505
    Pete Becker
    Nov 8, 2003
  5. Matt
    Replies:
    3
    Views:
    709
    Richard Heathfield
    Nov 8, 2003
Loading...

Share This Page