時間戳與標準時間的相互轉化

2021-07-06 04:22:50 字數 684 閱讀 5464

1.時間戳轉化為標準時間

unix時間戳(unix timestamp),或稱unix時間(unix time)、posix時間(posix time),是一種時間表示方式,定義為從格林威治時間2023年01月01日00時00分00秒(北京時間2023年01月01日08時00分00秒)起至現在的總秒數。但是時間戳轉化為標準時間的時候,要用毫秒進行轉換,所以給定的時間戳要乘以1000,轉化為毫秒

private

string fomattime(string formatstr)else

return sd;

}else

}

2.標準時間轉換為時間戳(毫秒)

******dateformat format=new ******dateformat("yyyy-mm-dd hh:mm:ss" );

string time="2015-10-25 0:0:0";

date date = null;

try catch (parseexception e)

system.out.print("format to times:"+date.gettime());

IOS 標準時間與時間戳 相互轉化

時間轉成時間戳 nstimezone zone nstimezone defaulttimezone 獲得當前應用程式預設的時區 nsinteger interval zone secondsfromgmtfordate nsdate date 以秒為單位返回當前應用程式與世界標準時間 格林威尼時間...

iOS標準時間與時間戳相互轉換

cpp view plain copy 設定時間顯示格式 nsstring timestr 2011 01 26 17 40 50 nsdateformatter formatter nsdateformatter alloc init autorelease formatter setdatest...

iOS標準時間與時間戳相互轉換

設定時間顯示格式 nsstring timestr 2011 01 26 17 40 50 nsdateformatter formatter nsdateformatter alloc init autorelease formatter setdatestyle nsdateformatterm...