The format-datetime() function

Smartsite 7.9 - ...

The format-datetime() extension function formats the specified date/time value, using the specified standard or custom format string.

XML CopyCode image Copy Code
string exf:format-datetime(arg1, arg2)

Parameters:

  • arg1: the date/time value to format (xml notation). 
  • arg2: the standard or custom format string.

Example

XML CopyCode image Copy Code
<html xmlns="http://www.w3.org/1999/xhtml" 
 xmlns:xf="http://www.w3.org/2002/xforms" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
 xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0">
 <head>
  <title>Example</title>
  <xf:model>
   <xf:instance>
    <data xmlns="">     
     <moddate xsi:type="xf:dateTime">2018-01-30T10:34:00.000</moddate>
    </data>
   </xf:instance>
  </xf:model>
 </head>
 <body>
  <xf:group ref="/data" appearance="full" xml:lang="nl-nl">
   <xf:label/>
   <xf:output value="concat('d: ', exf:format-datetime(string(moddate),'d'))" />
   <xf:output value="concat('D: ', exf:format-datetime(string(moddate),'D'))" />
   <xf:output value="concat('f: ', exf:format-datetime(string(moddate),'f'))" />
   <xf:output value="concat('F: ', exf:format-datetime(string(moddate),'F'))" />
   <xf:output value="concat('g: ', exf:format-datetime(string(moddate),'g'))" />
   <xf:output value="concat('G: ', exf:format-datetime(string(moddate),'G'))" />
   <xf:output value="concat('m: ', exf:format-datetime(string(moddate),'m'))" />
   <xf:output value="concat('o: ', exf:format-datetime(string(moddate),'o'))" />
   <xf:output value="concat('R: ', exf:format-datetime(string(moddate),'R'))" />
   <xf:output value="concat('s: ', exf:format-datetime(string(moddate),'s'))" />
   <xf:output value="concat('t: ', exf:format-datetime(string(moddate),'t'))" />
   <xf:output value="concat('T: ', exf:format-datetime(string(moddate),'T'))" />
   <xf:output value="concat('u: ', exf:format-datetime(string(moddate),'u'))" />
   <xf:output value="concat('U: ', exf:format-datetime(string(moddate),'U'))" />
   <xf:output value="concat('Y: ', exf:format-datetime(string(moddate),'Y'))" />
   
   <xf:output value="exf:format-datetime(string(moddate),'d MMMM yyyy')" />
   <xf:output value="exf:format-datetime(string(moddate),'dd MMMM yyyy HH:mm:ss')" />
  </xf:group>
 </body>
</html>

The result will be:

d: 30-1-2018
D: dinsdag 30 januari 2018
f: dinsdag 30 januari 2018 10:34
F: dinsdag 30 januari 2018 10:34:00
g: 30-1-2018 10:34
G: 30-1-2018 10:34:00
m: 30 januari
o: 2018-01-30T10:34:00.0000000
R: Tue, 30 Jan 2018 10:34:00 GMT
s: 2018-01-30T10:34:00
t: 10:34
T: 10:34:00
u: 2018-01-30 10:34:00Z
U: dinsdag 30 januari 2018 09:34:00
Y: januari 2018
30 januari 2018
30 januari 2018 10:34:00


Namespace

This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).