Specifications

w Day of the week as a single digit. Range is from 0(Sunday) to 6
(Saturday).
y Year in 2-digit format, for example, 00.
Y Year in 4-digit format, for example, 2000.
z Day of the year as a number. Range is 0 to 365.
Z Offset for the current timezone in seconds. Range is -43200to 43200.
Dealing with UNIX Time Stamps
The second parameter to the date() function is a UNIX time stamp.
In case you are wondering exactly what this means, most UNIX systems store the current time
and date as a 32-bit integer containing the number of seconds since midnight, January 1, 1970,
GMT, also known as the UNIX Epoch. This can seem a bit esoteric if you are not familiar with
it, but its a standard.
UNIX timestamps are a compact way of storing a date and time, but it is worth noting that they
do not suffer from the year 2000 (Y2K) problem that affects some other compact or abbrevi-
ated date formats. If your software is still in use in 2038, there will be similar problems
though. As timestamps do not have a fixed size, but are tied to the size of a C long, which is at
least 32 bits, the most likely solution is that by 2038, your compiler will use a larger type.
Even if you are running PHP on a Windows server, this is still the format that is used by
date() and a number of other PHP functions.
If you want to convert a date and time to a UNIX time stamp, you can use the mktime() func-
tion. This has the following prototype:
int mktime (int hour, int minute, int second, int month,
int day, int year [, int is_dst])
The parameters are fairly self-explanatory, with the exception of the last one, is_dst, which
represents whether the date was in daylight savings time or not. You can set this to 1 if it was,
0 if it wasnt, or -1 (the default value) if you dont know. This is optional so you will rarely
use it anyway.
The main trap to avoid with this function is that the parameters are in a fairly unintuitive order.
The ordering doesnt lend itself to leaving out the time. If you are not worried about the time,
Part Title
P
ART IV
394
TABLE 18.1 Continued
Code Description
23 7842 CH18 3/6/01 3:43 PM Page 394