Copied to clipboard

Flag this post as spam?

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


  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Aug 10, 2009 @ 16:33
    Warren Buckley
    0

    Outputting custom date/time with umbraco:item field?

    Hello all,
    Is it possible to ouput a custom formatDateTime with the umbraco:item field.

    Currently I have a field that stores a date for an event called startDate and I would like to display it out as
    10.08.09 15:30

    But using the attribute formatAsDateWithTime and formatAsDateWithTimeSeperator outputs it as 10th August 2009 15:30

    <umbraco:Item field="startDate" formatAsDateWithTime="true" formatAsDateWithTimeSeparator=" " runat="server"/>

    So is there a solution to this?

    Inline XSLT - Heard this can be resource intensive at times :S
    CodeBehind on masterpage?
    XSLT?
    Or other ...?

    What do you recommend?

    Thanks,
    Warren

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Aug 10, 2009 @ 16:36
    Douglas Robar
    1

    Use inline xslt and the umbraco.library (or exslt) extension. Double-check performance with the ?umbDebugshowTrace=true querystring, but I've not seen a performance issue with simple inline xslt. For more complex xslt I make a macro, and they don't have performance issues.

    cheers,
    doug.

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Aug 10, 2009 @ 16:37
    Warren Buckley
    0

    OK maybe i misheard then and more powerful inline XSLT is a performance hog. Looks like I may do it as inline XSLT to begin with unless anyone else has any suggestions?

    Thanks,
    Warren :)

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 10, 2009 @ 16:41
    Peter Dijksterhuis
    100

    Try this:

    <umbraco:Item runat="server" field="createDate" xslt="umbraco.library:FormatDateTime({0},'dd.MM.yy hh:mm')" />

    Cheers,

    Peter

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 10, 2009 @ 16:42
    Peter Dijksterhuis
    0

    Oh and change createDate to startDate ;)

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Aug 10, 2009 @ 16:42
    Warren Buckley
    0

    Thanks Peter, I was just about to put my solution up, which is the same apart from the field which sould be startDate :)

Please Sign in or register to post replies

Write your reply to:

Draft