跳轉到內容

C 程式設計/time.h/localtime

來自華夏公益教科書,開放的書籍,開放的世界

localtime()time.h 中的庫函式。它將日曆時間轉換為本地時間。

#include <time.h>
struct tm * localtime ( const time_t * ptr_time );

引數

指標 'ptr_time' 是指向包含日曆時間的 'time_t' 物件的指標。

返回值
函式 localtime() 返回指向 tm 結構的指標。tm 結構包含時間資訊。


函式 localtime() 使用指標 ptr_time 指向的時間來填充 tm 結構,其中包含表示對應本地時間的數值。如果呼叫此函式,它將以以下形式返回本地時間
"day Month date hr:min:sec year"((輸出)).

參考資料

[編輯 | 編輯原始碼]
華夏公益教科書