How to use timestamps (Part 1)

$now = time();
date('Y-m-d', 1750276608); // 2025-06-18
date('Y-m-d', 1946655003);
mktime(13, 30, 03, 15, 2018); // $expires = 2031-09-08
date('Y-m-d', 1773855003);
mktime(13, 30, 03, 15); // $expires = 2026-03-18
date('Y-m-d', 1750267803);
mktime(13, 30, 03); // $expires = 2025-06-18

How to get the parts of a timestamp

$expires = mktime(13, 30, 0, 3, 15, 2018);
$parts = getdate($expires);
$year = $parts['year'];
$mon = $parts['mon'];
$month = $parts['month'];
$weekday = $parts['weekday'];
$mday = $parts['mday'];
$wday = $parts['wday'];
$hours = $parts['hours'];
$minutes = $parts['minutes'];
$seconds = $parts['seconds'];

Back