go 日期時間轉換 常用資料轉換

2021-09-12 01:15:35 字數 817 閱讀 2477

base64解加密,bytes陣列轉string ,日期轉換

//installtime 是乙個經過encode和base64編碼後的資料 (即特定加密過後資料)時間戳

//解碼

date,_ := base64.stdencoding.decodestring(string(installtime))

//將byte陣列轉換為字串

str := string(date[:])

//載入本地時區

loc,_ := time.loadlocation("local")

//按照時區轉換時間戳

//這裡有個小彩蛋,猜猜為什麼是以這個時間字串作為基準2006-01-02 15:04:05

tm,_ := time.parseinlocation("2006-01-02 15:04:05", str, loc)

//獲取linux時間戳

installtimestamp := tm.unix()

//獲取當前時間 時間戳(秒)

time.now().unix()

//字串轉int

strconv.atoi("")   

//是否不存在

if os.isnotexist(err)

//是否存在

if os.i***ist(err)

//int64 轉string

strconv.formatint(int64,10)

//字串分割

strconv.split(str,split)

日期時間轉換

1 long 時間戳 to localdatetime private localdatetime parsingtimestamp long timestamp 2 long 時間戳 to 格式化時間字串 private static final datetimeformatter dtf dat...

js中常用日期時間轉換

常用日期時間處理外掛程式 1.timeago.js處理幾分鐘之前 2.day.js 3.moment.js 注意 1.此處的標準時間格式為 2018 03 23 13 35 47 2.此處的毫秒為 js中gettime 3.時間戳是指格林威治時間1970年01月01日00時00分00秒 北京時間19...

時間戳轉換日期 日期轉換時間戳 時間戳轉換星期

時間戳轉換日期 string date orderinfo.getchangetime replace null dateformat sdf new dateformat mm dd string monthdate sdf.format new date long.parselong date ...