Date time format in Ruby

 The most common uses of date time format in Ruby for reference

Code Output Description
t.strftime(“%H”) => “22” # Gives Hour of the time in 24 hour clock format
t.strftime(“%I”) => “10” # Gives Hour of the time in 12 hour clock format
t.strftime(“%M”) => “49” # Gives Minutes of the time
t.strftime(“%S”) => “27” # Gives Seconds of the time
t.strftime(“%Y”) => “2013” # Gives Year of the time
t.strftime(“%m”) => “09” # Gives month of the time
t.strftime(“%d”) => “12” # Gives day of month of the time
t.strftime(“%w”) => “4” # Gives day of week of the time
t.strftime(“%a”) => “Thu” # Gives name of week day in short form of the
t.strftime(“%A”) => “Thursday” # Gives week day in full form of the time
t.strftime(“%b”) => “Sep” # Gives month in short form of the time
t.strftime(“%B”) => “September” # Gives month in full form of the time
t.strftime(“%y”) => “13” # Gives year without century of the time
t.strftime(“%Y”) => “2013” # Gives year without century of the time
t.strftime(“%Z”) => “IST” # Gives Time Zone of the time
t.strftime(“%p”) => “PM” # Gives AM / PM of the time

(source: internet)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s