Formating Date picker with time using umbraco.library:FormatDateTime in xslt
I am trying to split up a date time value into its various components so I can pass them into a jquery plugin from an xslt macro. This is on 4.11.4
The Date Picker with time stores a value in (i think Xml time?) Example: 2013-06-06T13:25:00
I am trying to create a variable to hold each piece of the date with the following code:
<!-- get the value from Date Picker with time -->
<xsl:variable name="eventDateTime" select="$currentPage/eventDateTime" />
<!-- Split it up into the parts needed -->
<xsl:variable name="eventYear" select="umbraco.library:FormatDateTime($eventDateTime,'yyyy')"/>
<xsl:variable name="eventMonth" select="umbraco.library:FormatDateTime($eventDateTime,'M')"/>
<xsl:variable name="eventDay" select="umbraco.library:FormatDateTime($eventDateTime,'d')"/>
<xsl:variable name="eventHour" select="umbraco.library:FormatDateTime($eventDateTime,'H')"/>
<xsl:variable name="eventMinute" select="umbraco.library:FormatDateTime($eventDateTime,'m')"/>
But this generates an error:
System.Xml.Xsl.XslTransformException: An error occurred during a call to extension function 'FormatDateTime'. See InnerException for a complete description of the error. ---> System.FormatException: Input string was not in a correct format. at System.DateTimeFormat.GetRealFormat(String format, DateTimeFormatInfo dtfi) at System.DateTimeFormat.ExpandPredefinedFormat(String format, DateTime& dateTime, DateTimeFormatInfo& dtfi, TimeSpan& offset) at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset) at umbraco.library.FormatDateTime(String Date, String Format) --- End of inner exception stack trace --- at System.Xml.Xsl.Runtime.XmlExtensionFunction.Invoke(Object extObj, Object[] args) at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) at eventHour(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters) at umbraco.presentation.umbraco.developer.Xslt.xsltVisualize.visualizeDo_Click(Object sender, EventArgs e)
Formating Date picker with time using umbraco.library:FormatDateTime in xslt
I am trying to split up a date time value into its various components so I can pass them into a jquery plugin from an xslt macro. This is on 4.11.4
The Date Picker with time stores a value in (i think Xml time?) Example: 2013-06-06T13:25:00
I am trying to create a variable to hold each piece of the date with the following code:
But this generates an error:
What format is expected here? I was going by the information in this wiki article: http://our.umbraco.org/wiki/reference/umbracolibrary/formatdatetime
Thanks in advance,
-C.
FYI it was the format. I am going to try and update the wiki article.
As I see it, your problem lies here:
name="eventDateTime"select="$currentPage/eventDateTime"/>
You need something like:
name="eventDateTime"select="$currentPage/data [@alias='eventDateTime']"/>
is working on a reply...