Skip to content

Instantly share code, notes, and snippets.

@vhdm
Created September 6, 2015 20:43
Show Gist options
  • Save vhdm/14a0533646288436df02 to your computer and use it in GitHub Desktop.
Save vhdm/14a0533646288436df02 to your computer and use it in GitHub Desktop.
PHP provides over thirty-five case-sensitive characters that are used to format the date and time. These characters are
Day j Day of the Month, No Leading Zeros 1 - 31
Day d Day of the Month, 2 Digits, Leading Zeros 01 - 31
Day D Day of the Week, First 3 Letters Mon - Sun
Day l (lowercase 'L') Day of the Week Sunday - Saturday
Day N Numeric Day of the Week 1 (Monday) - 7 (Sunday)
Day w Numeric Day of the Week 0 (Sunday) - 6 (Saturday)
Day S English Suffix For Day of the Month st, nd, rd or th
Day z Day of the Year 0 - 365
Week W Numeric Week of the Year (Weeks Start on Mon.) 1 - 52
Month M Textual Representation of a Month, Three Letters Jan - Dec
Month F Full Textual Representation of a Month January - December
Month m Numeric Month, With Leading Zeros 01 - 12
Month n Numeric Month, Without Leading Zeros 1 - 12
Month t Number of Days in the Given Month 28 - 31
Year L Whether It's a Leap Year Leap Year: 1, Otherwise: 0
Year Y Numeric Representation of a Year, 4 Digits 1999, 2003, etc.
Year y 2 Digit Representation of a Year 99, 03, etc.
Time a Lowercase Ante Meridiem & Post Meridiem am or pm
Time A Uppercase Ante Meridiem & Post Meridiem AM or PM
Time B Swatch Internet Time 000 - 999
Time g 12-Hour Format Without Leading Zeros 1 - 12
Time G 24-Hour Format Without Leading Zeros 0 - 23
Time h 12-Hour Format With Leading Zeros 01 - 12
Time H 24-Hour Format With Leading Zeros 00 - 23
Time i Minutes With Leading Zeros 00 - 59
Time s Seconds With Leading Zeros 00 - 59
Timezone e Timezone Identifier Example: UTC, Atlantic
Timezone I (capital i) Whether Date Is In Daylight Saving Time 1 if DST, otherwise 0
Timezone O Difference to Greenwich Time In Hours Example: +0200
Timezone P Difference to Greenwich Time, With Colon Example: +02:00
Timezone T Timezone Abbreviation Examples: EST, MDT ...
Timezone Z Timezone Offset In Seconds -43200 through 50400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment