C programming under Linux ------ TIME

zhaozj2021-02-16  102

#include

#include

int main ()

{

INT I;

Time_t the_time;

StructTM * TM_PTR;

(void) Time (& THE_TIME);

TM_PTR = GMTIME (& THE_TIME);

Printf ("% D / N", 1900 TM_PTR-> TM_YEAR);

Printf ("% d / n", 1 TM_PTR-> TM_MON);

Printf ("% D / N", TM_PTR-> TM_MDAY;

Printf ("% D / N", TM_PTR-> TM_HOUR);

Printf ("% D / N", TM_PTR-> TM_MIN);

Printf ("% D / N", TM_PTR-> TM_SEC);

Printf ("% D / N", TM_PTR-> TM_WDAY);

Printf ("% D / N", TM_PTR-> TM_ISDST);

TM_PTR = LOCALTIME (& THE_TIME);

Printf ("% D / N", 1900 TM_PTR-> TM_YEAR);

Printf ("% d / n", 1 TM_PTR-> TM_MON);

Printf ("% D / N", TM_PTR-> TM_MDAY;

Printf ("% D / N", TM_PTR-> TM_HOUR);

Printf ("% D / N", TM_PTR-> TM_MIN);

Printf ("% D / N", TM_PTR-> TM_SEC);

Printf ("% D / N", TM_PTR-> TM_WDAY);

Printf ("% D / N", TM_PTR-> TM_ISDST);

Printf ("Time IS% S / N", Asctime (TM_PTR));

exit (0);

}

转载请注明原文地址:https://www.9cbs.com/read-10789.html

New Post(0)