Hi,
I have a doubt regarding time_t
I am initializing a time_t variable to 0.
When I display it, it shows "Thu Jan 1 07:30:00 1970" ?
I expected it to Thu Jan 1 00:0:00 1970 since t1 was initialized with 0
Pls let me know why this happens and how it can be rectified
Note:
Operating System - OS X (Mac)
Compiler - GCC
Given below is the code
Code:/* Aim - To set time_t variable to 01-Jan-1970 00:00:00 */ #include <iostream> #include <time.h> int main() { system("clear"); time_t t1(0); std :: cout << "t1 = " << ctime(&t1) << std :: endl; //Why does this display "Thu Jan 1 07:30:00 1970" ? //I expected it to "Thu Jan 1 00:0:00 1970", since t1 was initialized with 0 return(0); }




Reply With Quote
