xslttimegmtmdt

Convert GMT time local time in XSLT


How to convert GMT time to local time ( MDT or MST ) automatically.

I got this below working but i need a condition which determines utc -6 or utc -7 based on dates.

<xsl:value-of select="xs:dateTime($docdate) + xs:dayTimeDuration('-PT7H')"/>

Thanks Hari


Solution

  • You might look at the function adjust-time-to-timezone($arg as xs:time?), which adjusts the time given in $arg to the implicit timezone given in the dynamic context. There are no guarantees, but in many implementations that is likely to be the timezone set in the operating system environment.

    For example, if I evaluate the expression

    adjust-time-to-timezone( xs:time('20:45:00.0+01:00'))
    

    my system (current set to 7 hours west of UTC) returns the value

    12:45:00-07:00