On 2002.07.10, Rich <rich / lithinos.com> wrote:
> Todays date -
> 
> require "date"
> puts Date::today() # Output - 2002-07-09

Why require "date"?

Time.now.strftime("%Y-%m-%d")   # => "2002-07-09"

> Current time -
> 
> puts Time::now() # Output - Tue Jul 09 10:06:52 Mountain Daylight Time 2002

Time.now        # => Tue Jul 09 12:33:53 EDT 2002

For logfile naming using timestamps, I tend to use:

filename = "my_log"
logfile = "#{filename}#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")}"

If I'm creating temp files, I like to handle multiple files per
second, so I kludged this:

filename = "/dir/tempfile"
tempfile = "#{filename}#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")}#{(60000*rand).to_i}"

There's probably a better way to do the latter ...

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)