codegurukool.com · Free coding tutorials & online compiler

Home › PHP Tutorial › PHP date and time

PHP date and time

Format dates with date() and mktime().

date(format, timestamp) turns a timestamp into text: Y year, m month, d day, l weekday name. mktime builds a timestamp from hour, minute, second, month, day and year.

Example code

<?php
$t = mktime(0, 0, 0, 12, 25, 2026);
echo date("Y-m-d", $t) . PHP_EOL;
echo date("l", $t);
?>

Run this code in the online editor

← PHP superglobals and form handlingPHP cookies and sessions →