+ 3

how to display current time in a c++ program

11th Dec 2016, 12:01 PM
Arpit Luniya
Arpit Luniya - avatar
5 Antworten
+ 3
time(0) shows current time but it return variable of structure time_t inorder to access it u have to use another structure variable like time_t t=time(0). then using localtime()function u can output minute,hr,second,day,month,year anything
11th Dec 2016, 1:53 PM
manish rawat
manish rawat - avatar
+ 2
ya bro time.h or ctime
11th Dec 2016, 2:23 PM
manish rawat
manish rawat - avatar
+ 2
actually localtime also return pointer to structure named tm so u have to use it too like this struct tm* ptr=localtime(&t); then use tm-> day , tm->hour,tm->min freely
11th Dec 2016, 2:26 PM
manish rawat
manish rawat - avatar
+ 1
Should we include any particular header file for localtime() function
11th Dec 2016, 2:11 PM
Arpit Luniya
Arpit Luniya - avatar
+ 1
Ok thanks
11th Dec 2016, 3:49 PM
Arpit Luniya
Arpit Luniya - avatar