Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jan 29, 2010 @ 12:16
    Dan
    0

    Date format in umbraco datepicker field

    Hi,

    I have a page which uses a simple datepicker field to put a date on a page:

    <umbraco:Item field='articleDate' runat='server'></umbraco:Item>

    On other more complex pages (where there are lists of articles with dates etc) I've used a macro to generate the HTML, and in XSLT I've been able to format the date to a specified format (dd.mm.yyyy).  Is it possible to format the date in an umbraco field in a template, or do I need to create a macro just to output this date in a specific format?

    Thanks all...

  • Filip Duyck 4 posts 26 karma points
    Feb 01, 2010 @ 12:30
    Filip Duyck
    0

    I'm very curious about how to achieve this as well. Anyone?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 01, 2010 @ 13:03
    Dirk De Grave
    1

    Dan, Filip,

    Formatting can be done on the umbraco item. Just use the insert item dialog, and select to format as date. Date will be formatted according to the current culture settings (based on culture settings for the node, will default to en-US if not set through 'Manage hostnames')

    If you need more complex formatting, I'd suggest you use:

    <%=umbraco.library.FormatDateTime(umbraco.presentation.nodeFactory.Node.GetCurrent().getProperty("dateFieldProperty").Value, "format"); %>

    (exactly as you would use it from xslt)

    Hope this helps.

    Regards,

    /Dirk

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 01, 2010 @ 13:05
    Peter Dijksterhuis
    3

    If I am not mistaken, you could also set the language for the site which will then display dates in the format matching that language.

    HTH,

    Peter

  • Anthony Candaele 1197 posts 2049 karma points
    Apr 09, 2012 @ 20:09
    Anthony Candaele
    0

    Thanks Dirk,

    You saved my peace of mind, yet again. I should use the umbraco.library methods more often!

    greetings,

    Anthony

Please Sign in or register to post replies

Write your reply to:

Draft