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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access