We have moved to GitHub Issues
Created by Bo Mortensen 08 Oct 2012, 21:43:19 Updated by Sebastiaan Janssen 03 Nov 2016, 17:02:36
When using the umbraco.library:FormatDateTime(string Date, string Format) in Umbraco 4.9 to format a date (the create date of a node in this particular case) using slashes in the pattern returns the regular date format pattern: "08-10-12" rather than "08/10/12"
This occurs when using the following pattern: 'dd/MM/yy'.
Having looked at the FormatDateTime library method, it seems that it could be because the CultureInfo is not set when calling ToString(format) method. Possible fix: ToString("dd/MM/yy", CultureInfo.InvariantCulture) (or let the user pass in the culture as a parameter.)
Are you sure the culture in the frontend isn't just wrong?
Hi Sebastiaan, yes I have double checked that :-)
Right, what is the Format string that you're trying to use? I'll try to replicate.
The call to the umbraco.library:FormatDateTime looks like this: umbraco.library:FormatDateTime(@createDate, 'dd/MM/yy')
The format needs to be escaped to work, like so: 'dd/MM/yy' :-)
I have this in my XSLT macro
And the output is
Raw: 2014-09-05T12:27:52 Library: 05/09/14
which is what you would expect. You want to pass an explicit culture to ToString in order to ''not'' use the default one and I'm not sure why we would want to do this. And in any case, the culture impacts what ToString does when you ask it to return a "short date" or the name of a month... should have no impact on filtering slashes.
So... cannot repro. Would need more infos on how to reproduce.
@sebastiaan Can this issue be closed?
State: Can't Reproduce
Backwards Compatible: True
Due in version: