Home All Groups Group Topic Archive Search About
Author
23 Jan 2006 7:19 PM
Roshawn Dawson
Hi,

I have a datetime value that is already in GMT (UTC) time.  What I would like to do is convert this
value into Pacific Standard Time, but I also need to account for daylight savings time.

Simply subtracting eight hours from the value will give me the proper time (subtracting seven hours
if daylight savings time).  I tried using the TimeZone object to see if the value is in daylight
savings time like this

If TimeZone.IsDaylightSavingTime (value) = True Then
  value.AddHours(-7)
Else
  value.AddHours(-8)
End If

However, I always get a NullReferenceException (i.e. object reference not set to an instance of an
object) for the TimeZone object.

How do I properly use the TimeZone object?  Since it is labeled as MustInherit, do I need to create
an object that inherits the TimeZone object just to use this method?

Thanks,
Roshawn

Author
23 Jan 2006 7:47 PM
dkisting
Hi Roshawn,

I have the perfext fix for you.

www.TimeZoneSource.com

..NET component, both windows and web, very lightweight.

HTH

Dan
Roshawn Dawson wrote:
Show quoteHide quote
> Hi,
>
> I have a datetime value that is already in GMT (UTC) time.  What I would like to do is convert this
> value into Pacific Standard Time, but I also need to account for daylight savings time.
>
> Simply subtracting eight hours from the value will give me the proper time (subtracting seven hours
> if daylight savings time).  I tried using the TimeZone object to see if the value is in daylight
> savings time like this
>
> If TimeZone.IsDaylightSavingTime (value) = True Then
>   value.AddHours(-7)
> Else
>   value.AddHours(-8)
> End If
>
> However, I always get a NullReferenceException (i.e. object reference not set to an instance of an
> object) for the TimeZone object.
>
> How do I properly use the TimeZone object?  Since it is labeled as MustInherit, do I need to create
> an object that inherits the TimeZone object just to use this method?
>
> Thanks,
> Roshawn
Author
23 Jan 2006 7:55 PM
Roshawn Dawson
Hey, thanks for the resource!  :-)

dkist***@dankisting.com wrote:
Show quoteHide quote
> Hi Roshawn,
>
> I have the perfext fix for you.
>
> www.TimeZoneSource.com
>
> .NET component, both windows and web, very lightweight.
>
> HTH
>
> Dan