We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


How to format time XSL 1.0

JonCardona asked
Medium Priority
Last Modified: 2012-08-13
I'm trying to format this line to exclude the seconds at the end.

Any ideas?

<xsl:value-of select="TRANSACTION/PRINTTIME" />

I tried using format-time, then realized its not available in this version...
Watch Question

The answer is probably dependent on the format of the time itself.

One possibility which removes the last 2 characters
<xsl:value-of select="substring(TRANSACTION/PRINTTIME), 1, string-length(TRANSACTION/PRINTTIME) - 2)"/>


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Gertone (Geert Bormans)Information Architect
Top Expert 2006

Date formatting in XSLT is always a matter of substring operations
(unless you are using data-types in XSLT2.0)
functions to check are

substring(string, number, number)
substring-before(string, string)
substring-after(string, string)

also handy are
translate() and normalize-space()

it is important for us to know how the date format is in order to help
There is a fair chance that jkmyoungs solution works
of course you need a -3 instead of -2 if the format has an 's' for seconds

if your format is something like this
it could be safer to have
substring-after(substring-after(TRANSACTION/PRINTTIME, ':') , ':')
because that also works with this
12:24:5 instead of 12:24:05

all depends on what you have,
but you are into heavy substringing :)

most XSLT programmers have over time built their own little date processing library,
or use one of the many available "out there"

one thing worth checking out is EXSLT,
that is a standardised XSLT extension, that has some extra functionality,
There is a date library, and you never know it is supported by your processor,
just check it out www.exslt.org




This worked perfectly. Thanks!!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.