part of the groupelephant.com family
beyond corporate purpose

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