看板SetupBBS
標 題Re: <轉錄/Local Save> 三篇關於 date_stamp 實作
發信站亞特蘭提斯 (Fri Feb 12 12:35:34 2010)
轉信站ptt!news.ntu!news.au!zoonews.ee.ntu!News.leobbs.net!Atlantis
※ 引述《[email protected] ( )》之銘言:
: #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