PHP Date / Time Functions - how to create? - example

Example - How to create PHP date?
<?php
// Set the default time zone. Available starting with PHP 5.1
date_default_timezone_set('UTC');
echo "<br />";
// Show something like this: Monday
echo date("l");
echo "<br />";
// Show something like this: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A');
echo "<br />";
// View: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
echo "<br />";
/* using constants in format parameter */
// Show something like this: Wed, 25 Sep 2013 15:28:57 -0700

echo date(DATE_RFC2822);
echo "<br />";
// Show something like this: 2000-07-01T00: 00: 00 + 00: 00
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
echo "<br />";
?>
The result:

Monday
Monday 9th of March 2026 12:34:03 AM
July 1, 2000 is on a Saturday
Mon, 09 Mar 2026 00:34:03 +0000
2000-07-01T00:00:00+00:00


****************************************
Example - PHP Date

<?php
// Assume that today is March 10th, 2019 5:16:18 pm
// and we are in the time zone Mountain Standard Time (MST)


$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:
March 9, 2026, 12:34 am
03.09.26
9, 3, 2026
20260309
12-34-03, 9-03-26, 3431 3403 1 Monam26
it is the 9th day.
Mon Mar 9 0:34:03 UTC 2026
00:03:03 m is month
00:34:03
2026-03-09 00:34:03


****************************************