Locale FormatDateTime

The following code example demonstrates various datetime formattingĀ viper methods.

Smartsite SXML CopyCode image Copy Code
{buffer.set(d, datetime.getdate(1956, 12, 3, 5, 38, 59))}

<table>
<tr>
<th colspan="2">Default culture</th>
</tr>
<tr><td>Default formatted</td><td>{locale.formatdatetime($d)}</td></tr>
<tr><td>Custom formatted</td><td>{locale.formatdatetimecustom($d, 'dddd MM-dd-yy')}</td></tr>
<tr><td>Long date</td><td>{locale.formatlongdate($d)}</td></tr>
<tr><td>Long date, long time</td><td>{locale.formatlongdatelongtime($d)}</td></tr>
<tr><td>Long date, short time</td><td>{locale.formatlongdateshorttime($d)}</td></tr>
<tr><td>Long time</td><td>{locale.formatlongtime($d)}</td></tr>
<tr><td>Short date</td><td>{locale.formatshortdate($d)}</td></tr>
<tr><td>Short date and time</td><td>{locale.formatshortdatetime($d)}</td></tr>
<tr><td>Short time</td><td>{locale.formatshorttime($d)}</td></tr>
</table>

<table>
<tr>
<th colspan="2">nl-nl culture</th>
</tr>
<tr><td>Default formatted</td><td>{locale.formatdatetime($d,'nl-nl')}</td></tr>
<tr><td>Custom formatted</td><td>{locale.formatdatetimecustom($d, 'dddd MM-dd-yy', 'nl-nl')}</td></tr>
<tr><td>Long date</td><td>{locale.formatlongdate($d,'nl-nl')}</td></tr>
<tr><td>Long date, long time</td><td>{locale.formatlongdatelongtime($d, 'nl-nl')}</td></tr>
<tr><td>Long date, short time</td><td>{locale.formatlongdateshorttime($d, 'nl-nl')}</td></tr>
<tr><td>Long time</td><td>{locale.formatlongtime($d, 'nl-nl')}</td></tr>
<tr><td>Short date</td><td>{locale.formatshortdate($d, 'nl-nl')}</td></tr>
<tr><td>Short date and time</td><td>{locale.formatshortdatetime($d, 'nl-nl')}</td></tr>
<tr><td>Short time</td><td>{locale.formatshorttime($d, 'nl-nl')}</td></tr>
</table>
Example Result CopyCode image Copy Code
<table>
<tr>
<th colspan="2">Default culture</th>
</tr>
<tr><td>Default formatted</td><td>1956-12-03 05:38:59</td></tr>
<tr><td>Custom formatted</td><td>Monday 12-03-56</td></tr>
<tr><td>Long date</td><td>Monday, December 3, 1956</td></tr>
<tr><td>Long date, long time</td><td>Monday, December 3, 1956 05:38:59</td></tr>
<tr><td>Long date, short time</td><td>Monday, December 3, 1956 05:38</td></tr>
<tr><td>Long time</td><td>05:38:59</td></tr>
<tr><td>Short date</td><td>1956-12-03</td></tr>
<tr><td>Short date and time</td><td>1956-12-03 05:38</td></tr>
<tr><td>Short time</td><td>05:38</td></tr>
</table>

<table>
<tr>
<th colspan="2">nl-nl culture</th>
</tr>
<tr><td>Default formatted</td><td>3-12-1956 05:38:59</td></tr>
<tr><td>Custom formatted</td><td>maandag 12-03-56</td></tr>
<tr><td>Long date</td><td>maandag 3 december 1956</td></tr>
<tr><td>Long date, long time</td><td>maandag 3 december 1956 05:38:59</td></tr>
<tr><td>Long date, short time</td><td>maandag 3 december 1956 05:38</td></tr>
<tr><td>Long time</td><td>05:38:59</td></tr>
<tr><td>Short date</td><td>3-12-1956</td></tr>
<tr><td>Short date and time</td><td>3-12-1956 05:38</td></tr>
<tr><td>Short time</td><td>05:38</td></tr>
</table>