strptime(date, format, now=self.now) public

Parses date using Date._strptime and converts it to a Time object.

If a block is given, the year described in date is converted by the block. For example:

Time.strptime(...) {|y| y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y}

Below is a list of the formatting options:


The abbreviated weekday name (“Sun”)


The full weekday name (“Sunday”)


The abbreviated month name (“Jan”)


The full month name (“January”)


The preferred local date and time representation


Century (20 in 2009)


Day of the month (01..31)


Date (%m/%d/%y)


Day of the month, blank-padded ( 1..31)


Equivalent to %Y-%m-%d (the ISO 8601 date format)


Equivalent to %b


Hour of the day, 24-hour clock (00..23)


Hour of the day, 12-hour clock (01..12)


Day of the year (001..366)


hour, 24-hour clock, blank-padded ( 0..23)


hour, 12-hour clock, blank-padded ( 0..12)


Millisecond of the second (000..999)


Month of the year (01..12)


Minute of the hour (00..59)


Newline (n)


Fractional seconds digits, default is 9 digits (nanosecond)


millisecond (3 digits)


microsecond (6 digits)


nanosecond (9 digits)


Meridian indicator (“AM” or “PM”)


Meridian indicator (“am” or “pm”)


time, 12-hour (same as %I:%M:%S %p)


time, 24-hour (%H:%M)


Number of seconds since 1970-01-01 00:00:00 UTC.


Second of the minute (00..60)


Tab character (t)


time, 24-hour (%H:%M:%S)


Day of the week as a decimal, Monday being 1. (1..7)


Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)


VMS date (%e-%b-%Y)


Week number of year according to ISO 8601 (01..53)


Week number of the current year, starting with the first Monday as the first day of the first week (00..53)


Day of the week (Sunday is 0, 0..6)


Preferred representation for the date alone, no time


Preferred representation for the time alone, no date


Year without a century (00..99)


Year which may include century, if provided


Time zone as hour offset from UTC (e.g. +0900)


Time zone name


Literal “%” character

Show source
Register or log in to add new notes.