PHP date() & strtotime()

Interactive reference: test format strings, look up parameters, and try strtotime() expressions.

date(" ")
{{ dateResult }}
<?php echo date("{{ dateFormat }}"); ?>
{{ __t('th_character') }} {{ __t('th_description') }} {{ __t('th_example') }}
strtotime(" ")
{{ strtotimeResult.timestamp }}
{{ strtotimeResult.formatted }}
{{ strtotimeResult.relative }}
{{ strtotimePhpCode }}
{{ __t('alert_expression_not_recognized') }}
{{ cat.title }}
{{ __t('th_expression') }} {{ __t('th_description') }} {{ __t('label_result') }}
{{ ref.expr }} {{ ref.desc }} {{ getStrtotimeExample(ref.expr) }}

PHP date() — Format Parameters

The function date(string $format, ?int $timestamp = null) formats a Unix timestamp or the current time into a readable string. The format string consists of placeholders like Y (four-digit year), m (month with leading zero), d (day) or H:i:s (hours:minutes:seconds in 24h format).

PHP strtotime() — Relative Time Expressions

strtotime(string $datetime, ?int $baseTimestamp = null) converts English text descriptions into Unix timestamps. Typical inputs: "now", "+1 day", "next monday", "first day of next month", "last day of december 2025". The function is extremely flexible and also understands combined expressions like "+2 weeks 3 days".

Common Formats

  • date("Y-m-d") — ISO date: 2025-03-15
  • date("d.m.Y") — German format: 15.03.2025
  • date("Y-m-d H:i:s") — MySQL Datetime
  • date("c") — ISO 8601: 2025-03-15T14:30:00+01:00
  • date("r") — RFC 2822: Sat, 15 Mar 2025 14:30:00 +0100
  • date("U") — Unix timestamp