Time Conversion Functions

All date and time functions in this section require the include file <time.h>. In the remainder of this chapter, the following conversions will be examined:

  • time_t values to ASCII date/time strings

  • time_t values to date/time components (second, minute, hour, day, month, year, and so on)

  • Date/time components to ASCII strings

  • Date/time components to time_t values

In addition to looking at the various conversion functions, a simple C++ class DTime will be built and illustrated. This object has been left as simple as possible to prevent obscuring the underlying functions being discussed. For this reason, the DTime class in its present form is not entirely suitable for use in production-mode programs. The include file and the ...

Get Advanced UNIX Programming 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.