<?php


/*
Y: yyyy, y: yy,
n: m, m: mm, F: month, M: apprev of month to 3,
j: d, d: dd, l: day, D: appreav of day to 3,
g: h as 1-12 (1 or 2 dig)
G: h as 24 (1 or 2 dig)
h: h as 1-12 (2 dig)
H: h as 24 (2 dig)
i: minutes
s: seconds
a: am/pm
A: AM/PM
T: time zone
w: weekday as a number (day # of week)
W: week # of the year
S: Suffix for day (1st, 2nd, 3rd).
*/
$d = getdate();

echo "<p align=center><b>Using the getdate() function with no arguments:</b></p>";

echo 'After executing $d = getdate():<br>';
echo "\$d['year'] = {$d['year']}<br>";
echo "Without using the quotes in the key:<br>";
echo "\$d[year] = {$d[year]}<br>";
echo "\$d['month'] = {$d['month']}<br>";
echo "\$d['mday'] = {$d['mday']}<br>";
echo "\$d['hours'] = {$d['hours']}<br>";
echo "\$d['wday'] = {$d['wday']}<br>";
echo "\$d['weekday'] = {$d['weekday']}<br>";

echo "<p align=center><b>Using the getdate() function with an argument:</b></p>";

$e = getdate(filemtime("/home/abu-jeib/temp/a.txt"));

echo 'After executing $e = getdate(filemtime("/home/abu-jeib/temp/a.txt")):<br>';
echo "\$e['year'] = {$e['year']}<br>";
echo "\$e['month'] = {$e['month']}<br>";
echo "\$e['mday'] = {$e['mday']}<br>";
echo "\$e['hours'] = {$e['hours']}<br>";
echo "\$e['wday'] = {$e['wday']}<br>";
echo "\$e['weekday'] = {$e['weekday']}<br>";


/*
The date/gmdate function takes two arguments. The second one which is a Unix timestamp is optional. The first one is 
a string for formatting the date and time. If you use only the first argument, the date and time used by the 
date/gmdate function will be the current ones.

E.g.

echo "date('M d, y H:i:s',filemtime($file))<br>";
Here the last modified date of $file will be printed in the format M d, y H:i:s

echo "date('M d, y H:i:s')<br>";
Here the current date and time will be printed in the format M d, y H:i:s

*/

echo "<center><b>Now Using the date() function with one argument:</b></center><br>";
echo "date('r') = ", date('r'), "<br>";
echo "date('m/d/y') = ", date('m/d/y'), "<br>";
echo "date('m-d-y') = ", date('m-d-y'), "<br>";
echo "date('M d, y H:i:s T') = ", date('M d, y H:i:s T'), "<br>";
echo "date('D, M d, Y') = ", date('D, M d, Y'), "<br>";
echo "date('F jS, Y') =", date('F jS, Y'), "<br>";
echo "date('\T\h\e \t\i\m\e \i\s \n\o\w: H:i:s T') =", date('\T\h\e \t\i\m\e \i\s \n\o\w: H:i:s T'), "<br>";
echo "date('The time is now: H:i:s T') =", date('The time is now: H:i:s T'), "<br>";
/*
Note that when you use a letter in the date() function that is reserved for formatting the date, the letter will not 
be printed. Instead, it will be used for formatting. To print the letter as it's, proceed the letter with a backslash.
*/

echo "<b><p align=center>Now Using the gmdate() function with one argument:</b></p>";
echo "Note: gm stands for Greenwich Mean Time which is used in France and the UK.<br>";
echo "gmdate('r') = ", gmdate('r'), "<br>";
echo "gmdate('d/m/y') = ", gmdate('d/m/y'), "<br>";
echo "gmdate('d-m-y') = ", gmdate('d-m-y'), "<br>";
echo "gmdate('M d, y H:i:s T') = ", gmdate('M d, y H:i:s T'), "<br>";
echo "gmdate('D, M d, Y') = ", gmdate('D, M d, Y'), "<br>";
echo "gmdate('jS F Y') =", gmdate('jS F Y'), "<br>";

echo "<p align=center><b>Now using a second argument for the date() function:</b></p>";
echo "The last modified date of the file \"/home/abu-jeib/temp/a.txt\" is printed in the format M d, y 
H:i:s<p>";
echo "date('M d, y H:i:s',filemtime('/home/abu-jeib/temp/a.txt')) = ", 
date('M d, y H:i:s',filemtime('/home/abu-jeib/temp/a.txt')), "<br>";


echo "<p align=center><b>Now using a second argument for the gmdate() function:</b></p>";
echo "The last modified date of the file \"/home/abu-jeib/temp/a.txt\" is printed in the format M d, y
H:i:s<p>";
echo "gmdate('M d, y H:i:s',filemtime('/home/abu-jeib/temp/a.txt')) = ",
gmdate('M d, y H:i:s',filemtime('/home/abu-jeib/temp/a.txt')), "<br>";


?>
