Extracts the current timezone from $date-var.
If $date-var does not contain a timezone, the empty sequence is returned.
If the value of $date-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xf:get-timezone-from-date(xs:date? $date-var) —> xs:string?
Returns the current timezone as a string from $date-var.
Returns an empty sequence, if $date-var does not contain a timezone. (See examples below.)
The following example uses the get-timezone-from-date function with a timezone:
<tz>{xf:get-timezone-from-date(xs:date("2002-08-30-05:00"))}</tz>
The preceding query generates the following result:
<tz>-05:00</tz>
In the preceding query, the -05:00 string specifies the time is specified in the Eastern Standard timezone which is 5 hours behind Coordinated Universal Time (UTC).
The following example uses the get-timezone-from-date function with a timezone:
<tz>{xf:get-timezone-from-date(xs:date("2002-08-30Z"))}</tz>
The preceding query generates the following result:
<tz>00:00</tz>
In this preceding query, the Z means the time is being specified in Coordinated Universal Time (UTC), so no timezone is reported.
The following is an example of using the get-timezone-from-date function with no timezone specified:
<tz>{xf:get-timezone-from-date(xs:date("2002-08-30"))}</tz>
The preceding query generates the following result:
<tz/>
W3C get-timezone-from-date function description.
W3C date data type description.