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

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.