adTempus API
ArcanaDevelopment.adTempus.Shared Namespace / DateTimeHandling Class / ToUTCDateTime Method

In This Topic
    ToUTCDateTime Method
    In This Topic
    Returns a DateTime value storing the sourceDateTime converted to UTC, but with the DateTimeKind==unspecified.
    Syntax
    'Declaration
     
    
    Public Shared Function ToUTCDateTime( _
       ByVal sourceDateTime As DateTimeOffset _
    ) As Date
    public static DateTime ToUTCDateTime( 
       DateTimeOffset sourceDateTime
    )

    Parameters

    sourceDateTime
    Remarks
    If we use DateTimeOffset.UTCDateTime to create a UTC DateTime, it has the Kind set to UTC. If we later try to round-trip that DateTime back to a DateTimeOffset using ReadDateTimeOffset and a stored offset, DateTimeOffset throws an exception because it only accepts an offset of 0 for a UTC date time. So we have to do the conversion to UTC ourselves here.
    See Also