U4-1000 - Formatting datetime using umbraco.library:FormatDateTime(string Date, string Format) with slashes

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.)


Sebastiaan Janssen 10 Oct 2012, 12:28:16

Are you sure the culture in the frontend isn't just wrong?

Bo Mortensen 10 Oct 2012, 12:34:27

Hi Sebastiaan, yes I have double checked that :-)

Sebastiaan Janssen 10 Oct 2012, 12:36:29

Right, what is the Format string that you're trying to use? I'll try to replicate.

Bo Mortensen 10 Oct 2012, 12:39:58

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' :-)

Stephan 20 Nov 2014, 14:47:20

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.

Anthony 03 Nov 2016, 15:59:17

@sebastiaan Can this issue be closed?

Priority: Normal

Type: Bug

State: Can't Reproduce


Difficulty: Easy


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version:


Story Points: