亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12
最近訪問板塊 發(fā)新帖
樓主: aychxm
打印 上一主題 下一主題

[函數(shù)] 求一個時間個是轉(zhuǎn)換函數(shù) [復(fù)制鏈接]

論壇徽章:
0
11 [報告]
發(fā)表于 2013-08-08 12:49 |只看該作者
:wink:新手求助。!

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
12 [報告]
發(fā)表于 2013-08-09 09:41 |只看該作者
我們在用的代碼,應(yīng)該是你要的

  1. #include <time.h>
  2. #include <sys/time.h>

  3. /**
  4. * get the local date or time in specified time zone for the specified UTC timestamp.
  5. * you can pass NULL for pointer-typed parameters.
  6. * return 0 on sucess, return -1 if error occured.
  7. * @year will be the A.D number, @month will be 1~12, @mday will be 1~31
  8. */
  9. int util_time(time_t timestamp, int32_t* year, int32_t* month, int32_t* mday, int32_t* hour, int32_t* minute, int32_t* second, int32_t zone)
  10. {
  11.         timestamp += zone*3600;
  12.         struct tm tmresult;
  13.         if(NULL==gmtime_r(&timestamp, &tmresult))
  14.                 return -1;
  15.         if(NULL!=year)
  16.                 *year = tmresult.tm_year + 1900;
  17.         if(NULL!=month)
  18.                 *month = tmresult.tm_mon + 1;
  19.         if(NULL!=mday)
  20.                 *mday = tmresult.tm_mday;
  21.         if(NULL!=hour)
  22.                 *hour = tmresult.tm_hour;
  23.         if(NULL!=minute)
  24.                 *minute = tmresult.tm_min;
  25.         if(NULL!=second)
  26.                 *second = tmresult.tm_sec;
  27.         return 0;
  28. }
復(fù)制代碼
這樣調(diào)用
  1. util_time(stamp, &year, &mon, &mday, &hour, &minute, &second, 8);
復(fù)制代碼
然后自己sprintf一下就可以了

論壇徽章:
0
13 [報告]
發(fā)表于 2013-08-23 18:32 |只看該作者
http://www.cppblog.com/zdhsoft/archive/2013/06/27/201343.html 這里是我開發(fā)服務(wù)器常用的時間函數(shù),看看能不能對你有用。
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP