Re: <轉錄/Local Save> 三篇關於 date_stamp 實作

看板SetupBBS作者時間14年前 (2010/02/12 13:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《mosquito520.bbs@ptt.cc ( )》之銘言: : #include <time.h> : time_t mktime(struct tm *timeptr); : 這樣不就得到timestamp? : 然後丟給difftime就出來了不是? 呃 我要說聲抱歉 看了 m 兄的提點我才去男人一下 :) #include <stdio.h> #include <time.h> int main(void) { struct tm time_a; time_t now; time_a.tm_year = 2010 - 1900; time_a.tm_mon = 03; time_a.tm_mday = 25; time_a.tm_min = 0; time_a.tm_sec = 0; now = mktime(&time_a); printf("%d %s\n", (int)now, ctime(&now)); return 0; } Derived from the POSIX.1-1988 standard and ANSI C standard. 實在慚愧 早期沒注意到這個函式 1998 年我已經不太碰新東西了 ^^;;; 感謝指正 :) 再次感恩 Orz 不過也因為阿呆所以把加加減減給實作出來 /.\;;; -- Origin: Atlantis DN: bbs.bsd.com.tw IP : 203.70.65.27 ST: atlantis
文章代碼(AID): #1BTEVK1J (SetupBBS)
文章代碼(AID): #1BTEVK1J (SetupBBS)