Output Ruby duration in iso8601
问题 I'm looking to output duration in iso8601 format in ruby on rails for schema.org. I already know how to output the timestamp in iso8601. e.g. video.created_at.iso8601 What I'm looking to do now is output something in the format of: <meta itemprop="duration" content="PT1M33S" /> That's the iso8601 duration format. You can read about the spec at http://en.wikipedia.org/wiki/ISO_8601#Durations Currently I'm hacking in a strftime, but that's not ideal... Time.at(@video.duration).strftime('PT%MM: