Copied to clipboard

Flag this post as spam?

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


  • Kasper Dyrvig 246 posts 379 karma points
    Oct 29, 2010 @ 08:23
    Kasper Dyrvig
    0

    Convert 12-hour clock to 24-hour

    I'm working on receaving a xml-feed from World Weather Online... Works great. But I would like to show the observation time as 24-hour clock and not - as is send to me - as 12-hour clock.

    Fx: I would like to convert 04:45 PM to 16:45

    Enyone how has an idea to do that?

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Oct 29, 2010 @ 09:21
    Steen Tøttrup
    1

    What format do you get the date in? xml date? ie. 2010-10-29T04:45:00 or?

    You could try calling the ShortTime method (umbraco.library xslt extension) like this:

    <xsl:value-of select="umbraco.library:ShortTime(@date)" />

    If .NET can convert the content of @date to a DateTime, that should work. You might have to remember selecting a culture that uses 24-hours. This can be done in the Content tree, manage hostnames etc.

    Hope this helps, if not, let me know and I'll be a bit more specific.

     

  • Kasper Dyrvig 246 posts 379 karma points
    Oct 29, 2010 @ 10:15
    Kasper Dyrvig
    0

    The feed I get contains the clock as...

    <observation_time>07:40 AM</observation_time>

    But I think you are right! If I type

    <xsl:value-of select="umbraco.library:ShortTime('01:13 PM')" />

    I get "13:13". (Right now the feed shows 07:42 AM, so I can't use that for test)

    Thank you very much. I'll keep an eye on it this afternoon, and if it still works - then my problem is solved!

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Oct 29, 2010 @ 10:18
    Steen Tøttrup
    0

    No problem, remember to mark the thread as solved .. if everything is working this afternoon!

     

Please Sign in or register to post replies

Write your reply to:

Draft