C 시간 함수

C 의 몇 시간 함수, 작은 코드 를 써 서 모두 포함 시 킵 니 다.
#include 
#include 
#include 

int main()
{
    time_t now = time(NULL);
    printf("now utc is %d
", now); struct tm* gtmie = gmtime(&now); struct tm* ctmie = localtime(&now); time_t now2 = mktime(gtmie ); time_t now3 = mktime(ctmie ); assert (now==now2); assert (now==now3); printf("Time now is %s
", asctime(gtmie)); printf("Time now is %s
", asctime(ctmie)); printf("Time now is %s
", ctime(&now)); char buf[124]; size_t len; len = strftime(buf,124,"%Y-%m-%d %H:%M:%S %Z",gtmie); printf("Time now is %s
",buf); }

좋은 웹페이지 즐겨찾기