Chapter 21
It’s About Time
IN THIS CHAPTER
Programming time functions
Understanding the Unix epoch
Retrieving the current time
Displaying the date and time
Pausing program execution
It’s time to program! Or, to put it another way, it’s time to program time. The C library is bursting with various time-oriented functions, allowing you to not only report the current time but also display dates and times. You can even suspend a program’s execution — on purpose — providing you know the proper functions.
What Time Is It?
Does anyone have the time? Seriously, does anyone really know what time it is — or was?
Electronic devices have clocks, but this feature doesn’t make them the best timekeepers. In fact, most gizmos today constantly update their internal clocks by using an Internet time server. Otherwise, the clock on your computer, cell phone, or tablet would never be accurate.
When you program the time in C, you’re relying upon the device you’re using to accurately report the date and ...
Get C Programming For Dummies, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.