Prev | Current Page 389 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

1 are introduced.
The Unix Timestamp
Fitting the oft-incongruous aspects of our world into the rigorous constraints of a
programming environment can be a tedious affair. Such problems are particularly
prominent when dealing with dates and times. For example, suppose you are tasked
with calculating the difference in days between two points in time, but the dates are
provided in the formats July 4, 2007 3:45pm and 7th of December, 2007 18:17. As you
might imagine, figuring out how to do this programmatically would be a daunting
affair. What you need is a standard format, some sort of agreement regarding how all
dates and times will be presented. Preferably, the information would be provided in
some sort of standardized numerical format??”20070704154500 and 20071207181700,
324 CHAPTER 12 ?–  D ATE AND TIME
for example. In the programming world, date and time values formatted in such a
manner are commonly referred to as timestamps.
However, even this improved situation has its problems. For instance, this proposed
solution still doesn??™t resolve challenges presented by time zones, daylight saving
time, or cultural variances to date formatting. You need to standardize according to a
single time zone and devise an agnostic format that could easily be converted to any
desired format. What about representing temporal values in seconds and basing
everything on Coordinated Universal Time (UTC)? In fact, this strategy was embraced by
the early Unix development team, using 00:00:00 UTC January 1, 1970, as the base
from which all dates are calculated.


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