Prefix a '%' before the 'M' format specifier for a single digit month alone.
umbraco.library:FormatDateTime($myDate, '%M')
From microsoft:
Note that if the 'M' format specifier is used alone, without other custom format strings, it is interpreted as the standard month day pattern format specifier. If the 'M' format specifier is passed with other custom format specifiers or the '%' character, it is interpreted as a custom format specifier.
Great answer, Chris. Putting the % in front of the 'M' worked perfectly. This is on Microsoft, not Umbraco, but would it be prudent to also note this in our Wiki page?
umbraco.library:FormatDateTime($myDate, 'M') not working as expected
Umbraco 4.0.2.1
umbraco.library:FormatDateTime($myDate, 'M')
Should return single-digit month; 1 for January, 2 for February ... 12 for December.
I get full month name followed by two-digit day (January 01, December 24).
Prefix a '%' before the 'M' format specifier for a single digit month alone.
From microsoft:
Note that if the 'M' format specifier is used alone, without other custom format strings, it is interpreted as the standard month day pattern format specifier. If the 'M' format specifier is passed with other custom format specifiers or the '%' character, it is interpreted as a custom format specifier.
http://msdn.microsoft.com/en-us/library/8kb3ddd4(VS.71).aspx
-Chris
That is expected behavior, that is how the .NET date formatter works. Refer to the MSDN docs for full details on formatting dates: http://msdn.microsoft.com/en-us/library/zdtaw1bw(v=VS.100).aspx
Great answer, Chris. Putting the % in front of the 'M' worked perfectly. This is on Microsoft, not Umbraco, but would it be prudent to also note this in our Wiki page?
http://our.umbraco.org/wiki/reference/umbracolibrary/formatdatetime
Good idea. It has been done.
-Chris
is working on a reply...