Linux中,ctime庫函式的使用
阿新 • • 發佈:2019-02-02
幾個函式的定義:
atime: The time when the file was last accessed. (eg: cat)
ctime: The time when the file's status was last changed. (eg: chmod)mtime: The time when the file's data was last modified. (eg: vi)
用法:
double difftime(time_t time1, time_t time0); //計算兩個時間點之間的差值
time_t mktime(struct tm * timeptr); //把結構化時間轉化為日曆時間,即一個長整數
time_t time(time_t * timer); //通過引數timer獲得指定日曆時間,引數為NULL,代表當前時間
char * asctime(const struct tm * timeptr); //得到固定的時間格式
char * ctime(const time_t *timer); //得到固定的時間格式
struct tm * gmtime(const time_t *timer); //把日曆時間轉化為結構化時間
struct tm * localtime(const time_t * timer); //把日曆時間轉化為結構化時間(針對本地的)