Therefore, although you won??™t necessarily be able to remember how to use
this function simply by reviewing a few examples, let??™s look at the examples just to
give you a clearer understanding of what exactly date() is capable of accomplishing.
The first example demonstrates one of the most commonplace uses for date(),
which is simply to output a standard date to the browser:
echo "Today is ".date("F d, Y");
// Today is August 22, 2007
n Numeric representation
of month, without zeros
1 through 12
O Difference to Greenwich Mean
Time (GMT)
??“0500
r Date formatted according
to RFC 2822
Tue, 19 Apr 2007 22:37:00 ??“0500
s Seconds, with zeros 00 through 59
S Ordinal suffix of day st, nd, rd, th
t Total number of days in month 28 through 31
T Time zone PST, MST, CST, EST, etc.
U Seconds since Unix epoch
(timestamp)
1172347916
w Numeric representation
of weekday
0 for Sunday through 6 f
or Saturday
W ISO 8601 week number of year 1 through 52 or 1 through 53,
depending on the day in which
the week ends. See ISO 8601
standard for more information.
Y Four-digit representation of year 1901 through 2038 (Unix); 1970
through 2038 (Windows)
z Day of year 0 through 364
Z Time zone offset in seconds ??“43200 through 50400
Table 12-1. The date() Function??™s Format Parameters (Continued)
Parameter Description Example
328 CHAPTER 12 ?– D ATE AND TIME
The next example demonstrates how to output the weekday:
echo "Today is ".
Pages:
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405