Converts standard XSD time formats to characters suitable for output.
string ms:format-time(string datetime, string format [,locale])
string()
function were applied. If the argument is not a time, the output is an empty string. If it is a valid XSD time and some fields are empty, this function attempts to fill unspecified fields.GetTimeFormat
functions.The following lists the format characters for ms:format-time()
.
Character(s) | Description |
---|---|
h | Hours as 0-12 |
hh | Hours as 00-12 |
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 |
tt | Insert AM or PM, display hours as 12-hour clock |
t | Insert A or P, display hours as 12-hour clock |
XML Document: (Sample.xml)
<?xml version='1.0'?> <XMLSamples xml:space="preserve" xmlns:dt="urn:schemas-microsoft-com:datatypes"> <FileDetails> <Author>Robert Brown</Author> <Date dt:dt="datetime">2000-02-16T15:56:00</Date> </FileDetails> </XMLSamples>
XSLT Style sheet (Sample.xsl)
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:dt="urn:schemas-microsoft-com:datatypes"> <xsl:template match="/"> <HTML> <HEAD> </HEAD> <BODY> <xsl:for-each select="XMLSamples/FileDetails/Date"> <DIV> Time Unedited: <xsl:value-of select="."/> </DIV> <DIV> Time Edited: <xsl:value-of select="ms:format-time(., 'hh:mm:sstt')"/> </DIV> </xsl:for-each> </BODY> </HTML> </xsl:template> </xsl:stylesheet>
Try It
Output
The output HTML page shows the following entries:
Time Unedited: 2000-02-16T15:56:00 Time Edited: 03:56:00PM
Data Types in Schemas | XML Schema Reference (XSD) | XML Data Types Reference