Prev | Current Page 392 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Its prototype
follows:
1. Thirty days hath September, April, June, and November; All the rest have thirty-one, Excepting for
February alone, Which hath twenty-eight days clear, And twenty-nine in each leap year.
326 CHAPTER 12 ?–  D ATE AND TIME
string date(string format [, int timestamp])
Table 12-1 highlights the most useful parameters. (Forgive the decision to forgo
inclusion of the parameter for Swatch Internet Time.2)
If you pass the optional timestamp, represented in Unix timestamp format, date()
will return a corresponding string representation of that date and time. If the timestamp
isn??™t provided, the current Unix timestamp will be used in its place.
2. You can actually use date() to format Swatch Internet Time. Created in the midst of the dot-com
insanity, the watchmaker Swatch (http://www.swatch.com/) came up with the concept of ???Internet
time,??? which intended to do away with the stodgy old concept of time zones, instead setting time
according to ???Swatch Beats.??? Not surprisingly, the universal reference for maintaining Swatch Internet
Time was established via a meridian residing at the Swatch corporate office.
Table 12-1. The date() Function??™s Format Parameters
Parameter Description Example
a Lowercase ante meridiem and
post meridiem
am or pm
A Uppercase ante meridiem
and post meridiem
AM or PM
d Day of month, with leading zero 01 to 31
D Three-letter text representation
of day
Mon through Sun
F Complete text representation
of month
January through December
g 12-hour format, without zeros 1 through 12
G 24-hour format, without zeros 0 through 23
h 12-hour format, with zeros 01 through 12
H 24-hour format, with zeros 00 through 23
i Minutes, with zeros 01 through 60
I Daylight saving time 0 if no, 1 if yes
j Day of month, without zeros 1 through 31
l Text representation of day Monday through Sunday
L Leap year 0 if no, 1 if yes
m Numeric representation of month,
with zeros
01 through 12
M Three-letter text representation
of month
Jan through Dec
CHAPTER 1 2 ?–  D ATE AND T IME 327
Despite having regularly used PHP for years, many PHP programmers still need to
visit the documentation to refresh their memory about the list of parameters provided in
Table 12-1.


Pages:
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404