Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

<a href="/modules/moniwiki/wiki.php/manSearch?google=none&name=asctime">asctime</a>(3)

1장. asctime(3)

차례
1.1절. 사용법
1.2절. 설명
1.3절. 반환값
1.4절. 예제

시간을 (사람이)읽기 쉬운형태로 되돌려준다.


1.1절. 사용법

#include <time.h>

char *asctime(const struct tm *timeptr);
		


1.2절. 설명

timeptr구조체를 체워서 입력하면, 해당시간을 사람이 이해하기 쉬운 문자열로 되돌려준다.


1.3절. 반환값

ctime(3) 과 동일한 포맷으로 해당 시간을 표시한 문자열에 대한 포인터를 되돌려준다.


1.4절. 예제

#include <time.h>

#include <sys/types.h>
#include <stdio.h>

int main()
{
    struct tm *mytm;

    // 현재의 Unix Time 을 얻어온다. 
    time_t current_time = time((time_t*)NULL);
    // Unix Time 을 이용해서 tm 구조체를 채운다. 
    mytm = localtime(&current_time);
    // asctime 를 이용해서 보기쉬운 문자열로 변환한다. 
    printf("%s", asctime(mytm));

    return 0;
}