Jump to content

XSL Time formatting


Ender
 Share

This topic is 5661 days old. Please don't post here. Open a new topic instead.

Recommended Posts

On my xsl web page I have a portal with a time field, but the time is formatted in 24 hour format. How do I get it to display in 12 hour format? I know there are time formatting functions, but it's not clear how to apply them (this XML/XSL stuff is new to me.)

This is the code:












[b][/b]














































The 'eventdates::Time_Start' field is the one that needs formatting.

Link to comment
Share on other sites

You can use the fmxslt:convert_datetime(String oldFormat, String newFormat, String date) function for that.



  

    


      

        

              

        

      

  



If you want to count the hours 1-12 instead 0-11, use 'h:mm:ss a' instead of 'K:mm:ss a' .

BTW, in your code, you were comparing two literal values, 'eventdates::Time_Start' != '0:00:00', which of course is always true. Just don't put the field name in apostrophes. I had used a variable instead, because the field is used twice (in the xsl:when and in the xsl:value-of)

Link to comment
Share on other sites

This topic is 5661 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.