Return to 10to1.be

Under the Hat


Generating a timestamp string in Ruby

10 Jun 2009

In the hope that the Google Gods will help me next time I need this :-)

An easy way to generate a human-readable timestamp string, following the ISO 8601 standard, is:

Time.now.utc.iso8601.gsub('-', '').gsub(':', '')

Very handy if you need a timestamp in a file you’re writing.

blog comments powered by Disqus

About this blog

You’re reading Under the Hat, a weblog written by 10to1.

Who’s got the mic?