I have an XML with datetime data:
<A>
<StartDate>2011-11-01T00:00:00</StartDate>
<EndDate>2011-11-30T00:00:00</EndDate>
<IsRecurring>false</IsRecurring>
</A>
I need to get in xslt only the dates in the following format:
01/11/2011 - 30/11/2011
When I do:
<xsl:value-of select="A/StartDate/"> - <xsl:value-of select="A/EndDate/">
I get this:
2011-11-01T00:00:00 - 2011-11-30T00:00:00
How can I display it properly?
Can use the following conversion code to convert UTC format string to any other DateTime format. string result = Convert. ToDateTime("2011-02-04T00:00:00+05:30"). ToString("MM/dd/yyyy h:mm:ss tt");
XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG.
Look at XPath string functions: substring
, substring-before
and etc.
Reference: http://www.w3.org/TR/xpath/#section-String-Functions
<xsl:variable name="dt" select="'2011-11-01T12:13:59'"/>
<xsl:value-of select="concat(
substring($dt, 9, 2),
'/',
substring($dt, 6, 2),
'/',
substring($dt, 1, 4)
)"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With