<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.adjustDateTimeToTimezone.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.adjustDateTimeToTimezone</api:function-name><api:suggest>fn.adjustdatetimetotimezone</api:suggest><api:suggest>fn</api:suggest><api:suggest>adjustdatetimetotimezone</api:suggest><api:function-link mode="xquery" fullname="fn:adjust-dateTime-to-timezone">/apidoc/8.0/fn:adjust-dateTime-to-timezone.xml</api:function-link><api:function mode="javascript" name="adjustDateTimeToTimezone" type="builtin" lib="fn" category="DurationDateTimeBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.adjustDateTimeToTimezone"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">Adjusts an xs:dateTime value to a specific timezone, or to no
timezone at all. If $timezone is the empty sequence, returns an xs:dateTime
without a timezone. Otherwise, returns an xs:dateTime with a timezone.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $timezone is not specified, then $timezone is the value of the implicit
timezone in the dynamic context.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is the empty sequence, then the result is the empty sequence.
</p><p xmlns="http://www.w3.org/1999/xhtml">
A dynamic error is raised [err:FODT0003] if $timezone is less than -PT14H or
greater than PT14H or if does not contain an integral number of minutes.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg does not have a timezone component and $timezone is the empty
sequence, then the result is $arg.
</p><p xmlns="http://www.w3.org/1999/xhtml"> 
If $arg does not have a timezone component and $timezone is not the empty
sequence, then the result is $arg with $timezone as the timezone component.
</p><p xmlns="http://www.w3.org/1999/xhtml"> 
If $arg has a timezone component and $timezone is the empty sequence, then
the result is the localized value of $arg without its timezone component.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg has a timezone component and $timezone is not the empty sequence,
then the result is an xs:dateTime value with a timezone component of
$timezone that is equal to $arg.
</p>
</api:summary><api:params><api:param name="arg" type="xs:dateTime?"><api:param-description>
The dateTime to adjust to the new timezone.
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>Date?</api:param-type></api:param><api:param name="timezone" type="xs:dayTimeDuration?" optional="true"><api:param-description>
The new timezone for the dateTime.
  </api:param-description><api:param-name>timezone</api:param-name><api:param-type>xs.dayTimeDuration?</api:param-type></api:param></api:params><api:return>Date?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
Assume the dynamic context provides an implicit timezone
of -05:00 (-PT5H0M).

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00"))
=&gt; 2002-03-07T10:00:00-05:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00-07:00"))
=&gt; 2002-03-07T12:00:00-05:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00"), 
     xs.dayTimeDuration("-PT10H"))
=&gt; 2002-03-07T10:00:00-10:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00-07:00"), 
    xs.dayTimeDuration("-PT10H"))
=&gt; 2002-03-07T07:00:00-10:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00-07:00"),
    xs.dayTimeDuration("PT10H"))
=&gt; 2002-03-08T03:00:00+10:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T00:00:00+01:00"),
    xs.dayTimeDuration("-PT8H"))
=&gt; 2002-03-06T15:00:00-08:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00"), ())
=&gt; 2002-03-07T10:00:00

fn.adjustDateTimeToTimezone(
    xs.dateTime("2002-03-07T10:00:00-07:00"), ())
=&gt; 2002-03-07T10:00:00
</pre>
</api:example></api:function></api:function-page>