How to use timestamps (Part 1)

$now = time();
date('Y-m-d', 1767963584); // 2026-01-09
date('Y-m-d', 1978191003);
mktime(13, 30, 03, 15, 2018); // $expires = 2032-09-07
date('Y-m-d', 1804617003);
mktime(13, 30, 03, 15); // $expires = 2027-03-09
date('Y-m-d', 1767983403);
mktime(13, 30, 03); // $expires = 2026-01-09

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