Time Object Methods Used to Access Date/Time Attributes
Method | What the Method Returns |
---|---|
hour | A number representing the hour in 24-hour format ( 21 for 9 p.m., for example). |
min | The number of minutes past the hour. |
sec | The number of seconds past the minute. |
usec | The number of microseconds past the second (there are 1,000,000 microseconds per second). |
day | The number of the day in the month. |
mday | Synonym for the day method, considered to be "month" day. |
wday | The number of the day in terms of the week (Sunday is 0, Saturday is 6). |
yday | The number of the day in terms of the year. |
month | The number of the month of the date (11 for November, for example). |
year | The year associated with the date. |
zone | Returns the name of the time zone associated with the time. |
utc? | Returns true or false depending on if the time/date is in the UTC/GMT time zone or not. |
gmt? | Synonym for the utc? method for those who prefer to use the term GMT. |
These methods are for retrieving attributes from a date or time, and cannot be used to set them.
To change elements of a date or time, you'll either need to add or subtract seconds, or construct a new Time object using Time.gm or Time.local.