Example 1 — Read the Parts of a Date
Pass a fixed timestamp to getdate() and print the pieces you need.
<?php
date_default_timezone_set('UTC');
$d = getdate(1700000000);
echo $d['weekday'], ', ', $d['month'], ' ', $d['mday'], ', ', $d['year'], PHP_EOL;
echo $d['hours'], ':', $d['minutes'], ':', $d['seconds'], PHP_EOL; How It Works
- date_default_timezone_set('UTC') makes the result the same on every server.
- getdate(1700000000) returns an array describing 14 November 2023, 22:13:20.
- weekday and month are full English names, while mday and year are numbers.
- hours, minutes and seconds hold the time of day.

