tags:

views:

117

answers:

2

Id like to be able to convert the following XML

<itunes:duration>00:09:54</itunes:duration>

To a total of minutes, I currently just output the complete value but I would like to just display: 0hr 9min 54sec

Or possibly round up to the nearest minute?

+1  A: 

If you're using an XPath 2.0 supporting processor, there are built in functions you can use. Here's a list, scroll down to the date/time functions.

You probably want something like: minutes-from-time(time)

Watch out for namespace prefixes etc. A prefix isn't required for the functions if your processor dows support XPath 2.0

Brabster
A: 

If you just want to round up you can substring minutes and seconds, and if seconds > 30 -> minutes += 1

Tommy