TimeStringConvert (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 18: Line 18:


==Examples==
==Examples==
This statement converts a value in <code>YYYYMMDDHHMISSIIIIII</code> format to the <code>HH:MI:SS Mon DD, YYYY</code> format:
<ol>
<p class="code">%result = (%timestamp):timeStringConvert('YYYYMMDDHHMISSIIIIII', 'HH:MI:SS Mon DD, YYYY') </p>
<li>This statement converts a value in <code>YYYYMMDDHHMISSXXX</code> format to the <code>Month DAY, YYYY HH:MI:SS.XXX</code> format:
<p class="code">printText {~='20110520173648965':timeStringConvert('YYYYMMDDHHMISSXXX', 'Month DAY, YYYY HH:MI:SS.XXX')} </p>
 
The result is:
<p class="output">'20110520173648965':timeStringConvert('YYYYMMDDHHMISSXXX', 'Month DAY, YYYY HH:MI:SS.XXX')=May 20, 2011 17:36:48.965 </p>
 
<li>This statement converts a value in <code>MM/DD/YY</code> format to the <code>Month DAY, YYYY</code> format:
<p class="code">printText {~='12/22/11':timeStringConvert('MM/DD/YY', 'Month DAY, YYYY', centspan=1910)} </p>
 
The result is:
<p class="output">'12/22/11':timeStringConvert('MM/DD/YY', 'Month DAY, YYYY', centspan=1910)=December 22, 1911 </p>
 
</ol>


==See also==
==See also==


{{Template:String:TimeStringConvert footer}}
{{Template:String:TimeStringConvert footer}}

Revision as of 15:49, 3 April 2012

Convert date/time string from one format to another (String class)

[Introduced in Sirius Mods 7.9]


Syntax

%outString = string:TimeStringConvert( inputFormat, outputFormat, - [[CentSpan=] number]) Throws InvalidDateString

Syntax terms

%outString This string is the method object, string, converted to the format in outputFormat.
string A datetime string.
inputFormat The datetime format of the method object string.
outputFormat A string that is the format to which the method object is to be converted.
CentSpan This name allowed parameter is the CENTSPAN value used, if the format has a two-digit year. The default is specified by the CENTSPAN parameter.

Examples

  1. This statement converts a value in YYYYMMDDHHMISSXXX format to the Month DAY, YYYY HH:MI:SS.XXX format:

    printText {~='20110520173648965':timeStringConvert('YYYYMMDDHHMISSXXX', 'Month DAY, YYYY HH:MI:SS.XXX')}

    The result is:

    '20110520173648965':timeStringConvert('YYYYMMDDHHMISSXXX', 'Month DAY, YYYY HH:MI:SS.XXX')=May 20, 2011 17:36:48.965

  2. This statement converts a value in MM/DD/YY format to the Month DAY, YYYY format:

    printText {~='12/22/11':timeStringConvert('MM/DD/YY', 'Month DAY, YYYY', centspan=1910)}

    The result is:

    '12/22/11':timeStringConvert('MM/DD/YY', 'Month DAY, YYYY', centspan=1910)=December 22, 1911

See also