🤹
TALL Stack Tips
  • What is TALL Stack
  • Tailwind
    • Tailwind Resources
    • Swinging Bell Notification Icon
    • Styled Unordered Lists
  • Alpine
  • Alpine Resources
  • Tabbed Content Using Alpine JS
  • Checkbox component with SVG tick
  • Dropdown animation
  • Create a Sliding Puzzle Captcha
  • Laravel
    • Tabler Icons Component
    • Password-less Login with Laravel 8+
    • Password-less Login with Magic Link in Laravel 8
    • Laravel Resources
    • Laravel Breeze Login Conditional Redirect
    • Jetstream Login Conditional Redirect
    • Simplify Laravel CRUD Controllers
    • CSRF and expired login forms
    • CSRF and expired logout forms
    • Add your own logo to Laravel Mail
    • Specify a different mail theme for Notifications
    • Show custom page when email verification link expired
    • Using a mutator to save currency
    • Using Spatie Valuestore to hold frequently accessed settings
    • Using the old() helper
    • Alternatives to using Eloquent Accessor
    • UpdateOrCreate may not update timestamp
    • Use of lockForUpdate()
    • Using S3
    • Super Simple User Based Feature Flags
    • Installing a Specific Version of Laravel
    • Versioning your Laravel Project
    • CSS Cache Busting with your Git Commit SHA
    • Adding column to Database Notifications table
    • Find nearby locations using the Haversine formula in Eloquent query
    • Using Queues on Shared Hosting with Laravel
    • Create Guaranteed Unique Invoice Number in Laravel
    • Send Notification to all team members
    • Protect Staging site with Basic Auth
    • Working with Enums
    • PHP DateTime formatting cribsheet
  • Livewire
    • Livewire Resources
    • Naming Livewire Components
    • Dynamic Cascading Dropdown with Livewire
    • Hiding a button after click
    • Working with Javascript Components
    • SweetAlert2 with Livewire
    • Select Multiple or Checkboxes
    • Clearing checkboxes in Livewire
    • Livewire File Uploads Using S3
    • Simple Log File Viewer
  • Related Resources
    • Testing resources
    • When Composer runs out of memory
    • Deployment
    • Security
    • Scheduler & Cron tips
    • LastPass tips
    • Using Git
    • VSCode Tips
    • Markdown
    • Cpanel resources
Powered by GitBook
On this page

Was this helpful?

  1. Laravel

PHP DateTime formatting cribsheet

Describes the placeholders you can use when formatting dates in PHP or with Carbon

PreviousWorking with EnumsNextLivewire Resources

Last updated 4 years ago

Was this helpful?

Usage with php datetime object or

Hour

Character

Description

Example

H

24-hour format of an hour with leading zeros

00 through 23

G

24-hour format of an hour without leading zeros

0 through 23

h

12-hour format of an hour with leading zeros

01 through 12

g

12-hour format of an hour without leading zeros

1 through 12

a

Lowercase Ante meridiem and Post meridiem

am or pm

A

Uppercase Ante meridiem and Post meridiem

AM or PM

Minutes and Seconds

Character

Description

Example

i

Minutes with leading zeros

00 through 59

s

Seconds with leading zeros

00 through 59

u

Microseconds

eg 123456

v

Milliseconds

eg 654

Day

Character

Description

Example

d

Day of the month, 2 digits with leading zeros

01 through 31

j

Day of the month without leading zeros

1 through 31

D

Textual representation of a day, three letters

Mon through Sun**

l

(lowercase L) Full textual representation of a day of the week

Monday through

Sunday **

N

ISO-8601 numeric representation of the day of the week

1 through 7

(mon=1)

S

English ordinal suffix for the day of the month

st, nd, rd, or th

w

Numeric representation of the weekday

0 (sun) through 6

z

The day of the year (zero index for Jan 1)

0 through 365

Week

Character

Description

Example

W

ISO-8601 week number of year, weeks starting on Monday

Example: 42

(the 42nd week in the year)

Month

Character

Description

Example

m

Numeric representation of a month, with leading zeros

01 through 12

n

Numeric representation of a month, without leading zeros

1 through 12

M

A short textual representation of a month, three letters

Jan through Dec **

F

A full textual representation of a month, such as January or March

January through December

t

The number of days in the given month

28 through 31

Year

Character

Description

Example

Y

a four digit numeric representation of the year

2020 or 1999

y

a two digit numeric representation of the year

20 or 99

L

Whether it is a leap year

1 for leap year,

0 otherwise

o

ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.

2020 or 1999

** can be varied through localisation

Character

Description

Example

c

ISO 8601 Full Date Time

2020-06-26T13:40:10+00:00

r

formatted date

Fri, 26 Jun 2020 13:41:32 +0100

U

Seconds since the Unix Epoch (commonly referred to as timestamp format)

1593175400

Carbon
RFC 2822