C語言中時間戳轉換成時間字串的方法

2022-10-04 01:18:13 字數 457 閱讀 1488

在pe格式裡有個字段是檔案的建立時間戳,我想把轉成字串,這樣看的更直觀。

tchar buffer[50] = ;

struct tm tm = ;

time_t time = (time_t)ntheader->fileheader.timedatestamp;//時間戳

g &time);

printf(buffer, text("%d年%d月%d日 %d:程式設計客棧%d:%d"), tm.tm_year+1900, tm.tm_monbhnjag+1, tm.tm_mday, tm.tm_hour+8, tm.tm_min, tm.

//注意:這個函式計算出來的年份是自2023年起的多少年,所以要+1900,計算所得的月份0表示第乙個月以此來推,所以要+1,計算得到的時區不在我國,相差8個小時,所以要+8.

本文標題: c語言中時間戳轉換成時間字串的方法

本文位址:

時間戳轉換成時間

獲得當前時間戳,long型別 long timestamp system.currenttimemillis 要轉換成的時間格式 dateformat sdf new dateformat yyyy mm dd hh mm ss string sd sdf.format new date times...

時間轉換成時間戳

使用unix timestamp這個函式實現時間轉換成時間戳 mysql中的unix timestamp函式有兩種型別供呼叫 1 無引數呼叫 unix timestamp 返回值 自 1970 01 01 00 00 00 的到當前時間的秒數差 例子 select unix timestamp 13...

Perl 字串轉換成UNIX時間戳

最近遇到乙個需求,呼叫perl指令碼,由於自己不會perl硬著頭皮上 usr bin perl w 檢測是否是閏年 輸入引數年 數值型別 如 2017 sub is leap yearelse return flag 返回偏移後的unix時間戳 引數 年,月,日,偏移日期 可正可負 數值型別 如 2...