lua string 類型轉 time 類型

local function string2time( date,time )  --date:YYYYmmdd  time:HHMMSS
  local Y = string.sub(date , 1, 4)
  local m = string.sub(date , 5, 6)  
  local d = string.sub(date , 7, 8)  
  local H = string.sub(time , 1, 2)  
  local M = string.sub(time , 3, 4)  
  local S = string.sub(time , 5, 6)  
  return os.time({ year=Y, month=m, day=d,hour=H,min=M,sec=S})  

end


local function string2time( date,time )  --date: YYYYmmdd  time: HH:MM:SS
  local Y = string.sub(date , 1, 4)
  local m = string.sub(date , 5, 6)  
  local d = string.sub(date , 7, 8)  
  local H = string.sub(time , 1, 2)  
  local M = string.sub(time , 4, 5)  
  local S = string.sub(time , 7, 8)  
  return os.time({ year=Y, month=m, day=d,hour=H,min=M,sec=S})  
end

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章