Wednesday, May 16, 2012

Unix Date Format Specifiers

I could just remember to search wikipedia for "Date (Unix)" or search my site for "Unix". This was easier.

Source: Wikipedia: Date (Unix)

Format specifiers (format string starts with +)
Specifier Description Values/Example
Day
%a weekday, abbreviated Mon
%A weekday, full Monday
%d day of the month (dd), zero padded 04
%e day of the month (dd) 4
%j day of year, zero padded 001-366
%u day of week starting with Monday (1), i.e. mtwtfss 1
%w day of week starting with Sunday (0), i.e. smtwtfs 1
Week
%U week number Sunday as first day of week 01–53
%W week number Monday as first day of week 01–53
%V week of the year 01–53
Month
%m mm month 07
%h Mon Jul
%b Mon, locale's abbreviated Jul
%B locale's full month, variable length July
Year
%y yy two digit year 00–99
%Y ccyy year 2011
%g 2-digit year corresponding to the %V week number
%G 4-digit year corresponding to the %V week number
Century
%C cc century 00–99
Date
%D mm/dd/yy 07/4/11
%x locale's date representation (mm/dd/yy) 07/4/2011
%F %Y-%m-%d 2011-07-4
Hours
%l (Lowercase L) hour (12 hour clock) 1
%I (Uppercase I) hour (12 hour clock) zero padded 01
%k hour (24 hour clock) 13
%H hour (24 hour clock) zero padded 13
%p locale's upper case AM or PM (blank in many locales) PM
%P locale's lower case am or pm pm
Minutes
%M MM minutes 20
Seconds
%s seconds since 00:00:00 1970-01-01 UTC (Unix epoch) 1309785651
%S SS second 00–60
(The 60 is necessary to accommodate a leap second)
%N nanoseconds 000000000–999999999
Time
%r hours, minutes, seconds (12-hour clock) 01:20:51 PM
%R hours, minutes (24 hour clock) hh:mm e.g. 13:20
%T hours, minutes, seconds (24-hour clock) 13:20:51
%X locale's time representation (%H:%M:%S)
Date and Time
%c locale's date and time Sat Nov 04 12:02:33 EST 1989
Time zone
%z -zzzz RFC-822 style numeric timezone -0500
%Z time zone (e.g., EDT) nothing if no time zone is determinable EST

Add comment

Please note: all comments are reviewed before being published.


Security code
Refresh

Member Login

Joes Latest Members

A huge WELCOME goes to today's newest members:

  • infonat
Member Signups (Activated)
BeforeCurrentTrend
Day21=
Week105ê
Month11224ê
Year2,265612ê

Member Stats
56 guests are currently online.
1,178 members are still deciding.
There are 5,935 members in total.

Latest Comments

Paypal Donations

Want to support my work? Any donation is a blessing :c)