← All built-ins / date()

date()

date(...$args): string

Parameters

NameTypeDescription
$formatstringformat letters: Y y m n d j H G i s a A D l M N W t L U
$timestampintUnix timestamp (default: now)optional

Return value

The formatted date/time string (local time).

Example

echo date("Y-m-d", strtotime("2024-03-15 12:30:00")), "
";
echo date("H:i:s", strtotime("2024-03-15 12:30:00")), "
";
echo date("Y-m-d H:i:s", 1710508200), "
";
2024-03-15
12:30:00
2024-03-15 12:30:00

See also

strtotime()mktime()checkdate()