Free tool · runs in your browser
📅 PHP Date Format Builder & Timestamp Converter
Build a PHP date() format string by clicking, see the result live in any time zone, and convert Unix timestamps to dates and back, with copy-ready PHP code.
Result
date()
DateTimeImmutable
Format characters (click to add)
Day
- Day of the month, 2 digits (01–31)
- Day name, 3 letters (Mon–Sun)
- Day of the month without leading zero (1–31)
- Full day name (Monday–Sunday)
- ISO day of week (1 = Monday … 7 = Sunday)
- English ordinal suffix (st, nd, rd, th)
- Day of week (0 = Sunday … 6 = Saturday)
- Day of the year, from 0 (0–365)
Week
- ISO week number (01–53)
Month
- Full month name (January–December)
- Month, 2 digits (01–12)
- Month name, 3 letters (Jan–Dec)
- Month without leading zero (1–12)
- Days in the month (28–31)
Year
- Leap year (1 or 0)
- ISO week-numbering year
- Full year (e.g. 2026)
- Year, 2 digits (e.g. 26)
Time
- am or pm
- AM or PM
- 12-hour hour without leading zero (1–12)
- 24-hour hour without leading zero (0–23)
- 12-hour hour, 2 digits (01–12)
- 24-hour hour, 2 digits (00–23)
- Minutes, 2 digits (00–59)
- Seconds, 2 digits (00–59)
- Milliseconds (000–999)
- Microseconds (date() always prints 000000)
Time zone
- Time zone identifier (e.g. Europe/London)
- Daylight saving time in effect (1 or 0)
- Offset from UTC, no colon (+0530)
- Offset from UTC with colon (+05:30)
- Like P, but Z for UTC
- Time zone abbreviation
- Offset from UTC in seconds
Full
- ISO 8601 (2026-10-07T14:30:00+00:00)
- RFC 2822 (Wed, 07 Oct 2026 14:30:00 +0000)
- Unix timestamp (seconds)
Unix timestamp converter
Runs in your browser: what you enter is never sent anywhere. We only count anonymous usage, such as which buttons are used, to improve the tools.
How PHP date formats work
Each letter in a PHP format string stands for one part of the date: Y is the year, m the month, d the day, H:i:s the time. Any character that isn’t a format letter is printed as-is, and a backslash prints the next letter literally. The same letters work in date(), DateTimeInterface::format() and Carbon’s format().
Good habits with dates in PHP
- Store and compute in UTC, convert to the user’s time zone only for display.
- Prefer
DateTimeImmutableoverDateTime, so modifying a date never changes the original by surprise. - Use
Y-m-d H:i:sfor MySQLDATETIMEcolumns andDATE_ATOMorcfor APIs.
Frequently asked questions
How do I format a date as Y-m-d in PHP?
Use date('Y-m-d') for the current date, or $date->format('Y-m-d') on a DateTimeImmutable. Y is the four-digit year, m the two-digit month and d the two-digit day, for example 2026-10-07.
How do I convert a Unix timestamp to a date in PHP?
Use date('Y-m-d H:i:s', $timestamp), or (new DateTimeImmutable('@' . $timestamp))->setTimezone(new DateTimeZone('Europe/London'))->format('Y-m-d H:i:s') to control the time zone explicitly.
How do I put literal letters in a PHP date format?
Escape them with a backslash, for example date('l \t\h\e jS') prints “Wednesday the 7th”. In double-quoted PHP strings, escape the backslash too, or use single quotes.
Why does date() show the wrong time?
date() uses the default time zone from date.timezone in php.ini or date_default_timezone_set(). Set it explicitly (for example UTC on servers) and convert to the user’s zone only for display.