Skip to Content
Ruby Pocket Reference
book

Ruby Pocket Reference

by Michael Fitzgerald
July 2007
Beginner to intermediate
176 pages
2h 30m
English
O'Reilly Media, Inc.
Content preview from Ruby Pocket Reference

Time Formatting Directives

These directives in Table 20 are used with the method Time#strftime.

Table 20. Directives for formatting time

Directive

Description

%a

The abbreviated weekday name (Sun).

%A

The full weekday name (Sunday).

%b

The abbreviated month name (Jan).

%B

The full month name (January).

%c

The preferred local date and time representation.

%d

Day of the month (01 to 31).

%H

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

%I

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

%j

Day of the year (001 to 366).

%m

Month of the year (01 to 12).

%M

Minute of the hour (00 to 59).

%p

Meridian indicator (AM or PM).

%S

Second of the minute (00 to 60).

%U

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

%W

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

%w

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

%x

Preferred representation for the date alone, no time.

%X

Preferred representation for the time alone, no date.

%y

Year without a century (00 to 99).

%Y

Year with century.

%Z

Time zone name.

%%

Literal % character.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Ruby Pocket Reference, 2nd Edition

Ruby Pocket Reference, 2nd Edition

Michael Fitzgerald
Ruby Phrasebook

Ruby Phrasebook

Jason Clinton
Ruby by Example

Ruby by Example

Kevin C. Baird

Publisher Resources

ISBN: 9780596514815Errata Page