Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • rasb 162 posts 218 karma points
    Feb 03, 2010 @ 23:10
    rasb
    0

    Localized DateFormat

    Hi guys,

    I am trying to output a date from a property using Xslt. The page I am outputting is Danish, but the server has a US English locale. So when I use 

    <xsl:value-of select="umbraco.library:FormatDateTime($currentPage/data [@alias = 'eventStartDate'],'MMMM d, yyyy')"/>

    I get a date that looks like this: July 12, 2010

    I would like that to be displayed as the Danish string 12. juli 2010. instread.

    I looked at the ShortDateWithGlobal method using the da-DK culture. But that doesn't give me the a month name. It just displays like this 12-01-2010.

    Any input on how to display this correctly? I was thinking about creating a template to handle this, but figured that the Umbraco library would have a method to handle this.

    Thanks,
    RasB

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 03, 2010 @ 23:17
    Peter Dijksterhuis
    0

    Hi RasB,

    I think you have 2 options here. Instead of 'MMMM d, yyyy' try 'dd MMMM yyyy'

    Alternatively, you could add your da-culture to the web.config which will cause the dates to behave as Danish.

    (And thirdly, you could try setting a language to your home-node)

    HTH,

    Peter

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 03, 2010 @ 23:17
    Peter Dijksterhuis
    0

    Ok, strike the first option as the monthnames don't match....sorry for that

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Feb 04, 2010 @ 09:00
    Casey Neehouse
    0

    Have you thought about using the dictionary for your date formats?  I assume your site is in multiple languages as is?

  • rasb 162 posts 218 karma points
    Feb 04, 2010 @ 13:10
    rasb
    0

    I ended up changing the globalization tag in the web.config.

    For the moment I only have one language on the website and that is Danish. So that works for now. But I would have liked to be able to do that on the method call itself. Because I plan to do this in multiple languages.

    /RasB

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 04, 2010 @ 13:21
    Peter Dijksterhuis
    0

    In case of multi-language, you can assign multiple hostnames to the root (if you have seperate hostnames for each language), each having its own language assigned to it. That should work as well.

    Peter

  • Profiterole 232 posts 264 karma points
    Feb 09, 2010 @ 16:13
    Profiterole
    0

    Hi, my problem looks like rasb's one. My entire site is in french, but when I use FormatDateTime it gives me english name of months. July instead of Juillet for instance. The first and third ideas of Peter doesn't change anything. So I want to try the second one, but what do I have to change in my web.config file? I already look the globalization tag and it gives me UTF-8, which is the enconding I want.

Please Sign in or register to post replies

Write your reply to:

Draft