Prev | Current Page 395 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Its prototype follows:
mixed gettimeofday([boolean return_float])
For those running PHP 5.1.0 and newer, the optional parameter return_float
causes gettimeofday() to return the current time as a float value. In total, four
elements are returned:
??? dsttime: The daylight saving time algorithm used, which varies according to
geographic location. There are 11 possible values: 0 (no daylight saving time
enforced), 1 (United States), 2 (Australia), 3 (Western Europe), 4 (Middle Europe),
5 (Eastern Europe), 6 (Canada), 7 (Great Britain and Ireland), 8 (Romania),
9 (Turkey), and 10 (the Australian 1986 variation).
??? minuteswest: The number of minutes west of Greenwich Mean Time (GMT).
??? sec: The number of seconds since the Unix epoch.
??? usec: The number of microseconds should the time fractionally supercede a whole
second value.
Executing gettimeofday() from a test server on February 24, 2007 16:18:04 produces
the following output:
330 CHAPTER 12 ?–  D ATE AND TIME
Array (
[sec] => 1172351884
[usec] => 321924
[minuteswest] => 300
[dsttime] => 1
)
Of course, it??™s possible to assign the output to an array and then reference each
element as necessary:
$time = gettimeofday();
$GMToffset = $time['minuteswest'] / 60;
printf("Server location is %d hours west of GMT.", $GMToffset);
This returns the following:
Server location is 5 hours west of GMT.
Converting a Timestamp to User-Friendly Values
The getdate() function accepts a timestamp and returns an associative array consisting
of its components.


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