This tutorial will teach you how to show the date and time using PHP. To begin, start the PHP with the PHP tags.
| <?PHP
?> |
Then to add in the date and time, put:
| <?PHP
echo date (" ") ?> |
You put the date and time functions in the (" "). A list of all of the PHP date and time functions and what they do is shown below.
Time
A = Uppercase 12hr time syntax --- eg. PM, AM
a = Lowercase 12hr time syntax --- eg. pm, am
G = Hours in 24 hour format without leading zeros --- eg. 13
g = Hours in 12 hour format without leading zeros --- eg. 3
H = Hours in 24 hour format with leading zeros --- eg. 13
h = Hours in 12 hour format with leading zeros --- eg. 03
i = Minutes eg. 32 s = Seconds eg. 45
T = Timezone setting eg. GMT, PST, EST, etc
O = GMT time difference in hours eg. +0400
Date
D = Day --- eg. Fri
d = Day --- eg. 03
F = Full Text Month --- eg. January
M = Month --- eg. Jan
m = Month --- eg. 01
S = Day of month suffix --- eg. st, nd, rd, or th.
t = Total numer of days in the month --- eg. 28, 31, etc.
U = Seconds since the UNIX epoch --- eg. 1041604168
W = Week number in year --- eg. 42 (42nd week in the year)
w = numeric representation of the day --- eg. 1 = monday, 2 = tuesday, etc.
Y = Year --- eg. 2005
y = Year --- eg. 05
z = Day of the year --- eg. 002
For example
| <?PHP
echo date ("D dS F, Y g:i:s a") ?> |
That code would produce:
Fri 03rd January, 2005 3:32:45 pm
Experiment and work out what works best for you.












