Time

The time class.

self + other

Returns a time that is later than self by other seconds.

self - other

When other is a Time object, returns the difference between the two times with Float. If other is a numeric value, returns a time that is earlier than self by other.

self <=> other

Compares times. other must be a Time object or a numeric value; if a numeric value, the times are compared in terms of seconds since the epoch began.

strftime(format)

Returns the time, having been converted into a string via a format string. The format string may be specified with the following:

  • %A

    Day of the week (Sunday, Monday ... )

  • %a

    Day of the week, abbreviated (Sun, Mon ... )

  • %B

    Month (January, February ... )

  • %b

    Month, abbreviated (Jan, Feb ... )

  • %c

    Date and time

  • %d

    Day of the month (01-31)

  • %H

    Time of day, 24-hour format (00-23)

  • %I

    Time of day, 12-hour format (01-12)

  • %j

    Day of the year (001-366)

  • %M

    Minutes (00-59)

  • %m

    Month of the year (01-12)

  • %p

    AM or PM

  • %S

    Seconds (00-60, 60 being a leap second)

  • %U

    Week of the year, the first week starting with the first Sunday (00-53)

  • %W

    Week of the year, the first week starting with the first Monday (00-53)

  • %w

    Day of the week (0-6, 0 denoting Sunday)

  • %X

    Time

  • %x

    Date

  • %Y

    Year, 4-digit

  • %y

    Year, 2-digit (00-99)

  • %Z

    Time zone

  • %%

    The character %

sec

Returns the seconds.

min

Returns the minutes.

hour

Returns the hour.

mday

Returns the day.

mon

Returns the month.

year

Returns the year.

wday

Returns the number representing the day of the week.

Last updated