Microsoft XML SDK 2.6 - XML Reference

formatTime Method

Formats the supplied time using the specified formatting options.

formatTime(varTime, bstrFormat, varDestLocale)

Parameters

varTime
Variant. Time value that is to be formatted.
bstrFormat
String. Specified formatting to be applied to the time. The following codes are supported:
h Hours as 0-23
hh Hours as 00-23
m Minutes as 0-59
mm Minutes as 00-59
s Seconds as 0-59
ss Seconds as 00-59
AM/PM Insert AM or PM, display hours as 12-hour clock
am/pm Insert am or pm, display hours as 12-hour clock
A/P Insert A or P, display hours as 12-hour clock
a/p Insert a or p, display hours as 12-hour clock
[h]:mm Elapsed time in hours; for example, 25.02
[mm]:ss Elapsed time in minutes; for example, 63:46
[ss] Elapsed time in seconds
ss.00 Fractions of a second
varDestLocale [optional]
Variant. Locale to use in determining the correct sequence to be employed in the time.

Note   This parameter is not yet implemented.

Return Value

String. Returns the string containing the time in the requested format.

Example

<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="Sample.xsl"?>
<XMLSamples xml:space="preserve"
         xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <FileDetails>
   <Author>Amit S. Kripalani</Author>
   <Date dt:dt="datetime">2000-02-16T15:56:00</Date>
  </FileDetails>
</XMLSamples>

Sample.xsl

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"
      xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <xsl:template match="/">
  <HTML>
  <HEAD>
  </HEAD>
  <BODY> 
   <xsl:for-each select="XMLSamples/FileDetails/Date">
   Date Edited : 
<xsl:eval>
formatTime(this.nodeTypedValue, "hh:mm:ss");
</xsl:eval>
   </xsl:for-each>
  </BODY> 
  </HTML>
</xsl:template>
</xsl:stylesheet>

Output

Time Edited : 03:56:00

See Also

Applies To: XTLRuntime Object