#include <stdio.h> #include <time.h> int main() { time_t now; time(&now); printf("It's %s", ctime(&now)); return 0; }
用函數 strftime() 可以控制輸出的格式。 如果你需要小於秒的解析度, 參見問題 19.36。
參考資料: [K&R2, Sec. B10 pp. 255-7]; [ISO, Sec. 7.12]; [H&S, Sec. 18]。
翻譯朱群英、孫雲, LaTeX2HTML 編譯 朱群英 (2005-06-23)