PHP Date / Time Functions - how to create? - example
Example - How to create PHP date?
<?php
date_default_timezone_set('UTC');
echo "<br />";
echo date("l");
echo "<br />";
echo date('l jS \of F Y h:i:s A');
echo "<br />";
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
echo "<br />";
echo date(DATE_RFC2822);
echo "<br />";
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
echo "<br />";
?>
The result:
Friday
Friday 29th of August 2025 11:59:01 PM
July 1, 2000 is on a Saturday
Fri, 29 Aug 2025 23:59:01 +0000
2000-07-01T00:00:00+00:00
****************************************
Example - PHP Date
<?php
$today = date("F j, Y, g:i a");
// March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (formatul MySQL DATETIME)
?>
The result:
August 29, 2025, 11:59 pm
08.29.25
29, 8, 2025
20250829
11-59-01, 29-08-25, 5931 5901 5 Fripm25
it is the 29th day.
Fri Aug 29 23:59:01 UTC 2025
23:08:01 m is month
23:59:01
2025-08-29 23:59:01
****************************************