Getting a precise timestamp

I am new to Ruby and am trying to get the precise time (down to a
fraction
of a second). For example, I did this:

require ‘date’
now = DateTime.now
puts sprintf (“The current time is: %2d:%2d:%5.2f”, now.hour, now.min,
now.sec+now.sec_fraction)

However, I discover that now.sec_fraction is always zero. Am I not using
the
right object?

Thanks in advance for any help.

A Ma

[email protected] writes:

I am new to Ruby and am trying to get the precise time (down to a fraction
of a second). For example, I did this:

Time.new
Time.new.usec

YS.

“Yohanes S.” [email protected] wrote in
message
news:[email protected]

YS.

It works. Thanks a lot for your help.

A Ma

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs