This guide provides equivalent date/time format strings across popular environments (PHP, Linux, Ruby, etc.), with examples and tips. Also includes standard formats like ISO 8601 and RFC 2822.
Format Purpose | PHP Format | Linux/Ruby/POSIX Format | Example Output |
---|---|---|---|
Full Date/Time | d-m-Y H:i T |
%d-%m-%Y %H:%M %Z |
05-07-2025 14:23 CEST |
Short Date | d-m-Y |
%d-%m-%Y |
05-07-2025 |
Long Date | l, j F Y |
%A, %-d %B %Y |
Saturday, 5 July 2025 |
Time Only | H:i T |
%H:%M %Z |
14:23 CEST |
Use
%e
(or%-d
) instead of%d
for day without leading zero in POSIX-based formats. PHP usesj
.
Description | PHP | POSIX strftime (Linux, Ruby, Python) |
---|---|---|
Year (4-digit) | Y |
%Y |
Year (2-digit) | y |
%y |
Month (2-digit) | m |
%m |
Month (short name) | M |
%b |
Month (full name) | F |
%B |
Day (2-digit) | d |
%d |
Day (no leading zero) | j |
%e or %-d |
Weekday (short) | D |
%a |
Weekday (full) | l |
%A |
Hour (24h) | H |
%H |
Hour (12h) | h |
%I |
Minutes | i |
%M |
Seconds | s |
%S |
AM/PM | A /a |
%p |
Timezone (abbreviation) | T |
%Z |
Timezone (offset) | P |
%z |
Format Name | Format String / Spec | Example Output | Notes |
---|---|---|---|
ISO 8601 | Y-m-d\TH:i:sP (PHP) %Y-%m-%dT%H:%M:%S%z (POSIX) |
2025-07-05T14:23:00+02:00 |
Canonical international format (sortable) |
RFC 2822 | r (PHP) %a, %d %b %Y %H:%M:%S %z |
Sat, 05 Jul 2025 14:23:00 +0200 |
Used in email headers |
Unix Timestamp | U (PHP) %s (GNU date only) |
1751814180 |
Seconds since 1970-01-01 UTC |
PHP
echo date("d-m-Y H:i T"); // 05-07-2025 14:23 CEST
echo date("c"); // ISO 8601
echo date("r"); // RFC 2822
Linux
date "+%d-%m-%Y %H:%M %Z"
date --iso-8601=seconds
Ruby
Time.now.strftime("%d-%m-%Y %H:%M %Z")
Time.now.iso8601
Time.now.rfc2822
For maximum clarity, always show timezone abbreviation (%Z
) or offset (%z
), especially in global apps or transactional logs.