instance method
Time#gmtime
() -> ::Time
utc -> self
time.c
View on GitHub ↗
static VALUE
time_gmtime(VALUE time)
{
struct time_object *tobj;
struct vtm vtm;
GetTimeval(time, tobj);
if (TZMODE_UTC_P(tobj)) {
if (tobj->vtm.tm_got)
return time;
}
else {
time_modify(time);
}
vtm.zone = str_utc;
GMTIMEW(tobj->timew, &vtm);
time_set_vtm(time, tobj, vtm);
tobj->vtm.tm_got = 1;
TZMODE_SET_UTC(tobj);
return time;
}
Returns self, converted to the UTC timezone:
Example
t = Time.new(2000) # => 2000-01-01 00:00:00 -0600 t.utc? # => false t.utc # => 2000-01-01 06:00:00 UTC t.utc? # => true
Related: Time#getutc (returns a new converted Time object).