複製鏈接
請複製以下鏈接發送給好友

asctime

鎖定
函數原型char* asctime (const struct tm * timeptr).
中文名
asctime
函數原型
char* asctime
功    能
換為字符串字符串格式返回
格式為
Www Mmm dd hh

目錄

asctime功能

把timeptr指向的tm結構體中儲存的時間轉換為字符串,返回的字符串格式為:Www Mmm dd hh:mm:ss yyyy。其中Www為星期;Mmm為月份;dd為日;hh為時;mm為分;ss為秒;yyyy為年份。

asctime使用範例

/* asctime example */
#include <stdio.h>      /* printf */
#include <time.h>       /* time_t, struct tm, time, localtime, asctime */

int main ()
{
    time_t rawtime;
    struct tm * timeinfo;

    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    printf ( "The current date/time is: %s", asctime (timeinfo) );

    return 0;
}
函數範例的輸出:
The current date/time is: Wed Feb 13 15:46:11 2013
備註:以上的範例輸出是由TDM-GCC編譯器編譯後運行的結果,在使用其他的編譯器在不同語言環境中可能會出現其他的結果。