1#include <iostream>2#include <Ctime>3 using namespacestd;4 5 intMain ()6 {7 time_t t;8Time (&t); 9cout<<"Now is :"<<ctime (&t) <<Endl;Ten return 0; One}
"NOTE"
The following definitions are available for time_t,<time.h>:
------------------------------------------------------------------------------
#ifndef _time_t_defined
typedef long time_t; /* Time value */
#define _TIME_T_DEFINED/* Avoid multiple def ' s of time_t */
#endif
------------------------------------------------------------------------------
In other words, the time_t type is actually a long int type.
Time function Prototype:
time_t Time (time_t * timer);
The return value is the same as the value of the timer, which represents the number of seconds between 0:0 and 0 seconds from January 1, 1970, in fact a long int from 32-bit lengths can only be represented to January 18, 2038 19:14 07 seconds.
CTime function Prototypes:
Char *ctime (const time_t *timer);
//Convert the timer to a more intuitive time representation [day of the week: minutes: seconds ], and returned as a string.
"C + +" gets the current system time