Learning Ruby

How to get UTC time

The Time method "utc" will convert your time object to UTC.
The Time method "utc?" will let you know if the time is in UTC time (GMT).


t = Time.now 
# => 2009-10-05 16:56:54 -0700
t.utc?
# => false
t.utc
# => 2009-10-05 23:56:54 UTC
t.utc?
# => true

 

 

January 05, 2010 at 2:57 am