lua time tool

How to share a few lua time


function TimeTool:time(second_)
	if second_>=3600*24 then
		return string.format("%dd %02d:%02d:%02d", math.floor(second_/ (3600*24) ), math.floor((second_%(3600*24))/3600), math.floor((second_%3600)/60), math.floor(second_%60))
	elseif second_>=3600 then
		return string.format("%02d:%02d:%02d", math.floor(second_/3600), math.floor((second_%3600)/60), math.floor(second_%60))
	elseif second_>=60 then
		return string.format("%02d:%02d", math.floor(second_/60), math.floor(second_%60))
	end
	if second_ < 0 then second_ = 0 end
	return string.format("00:%02d", math.floor(second_))
end



function TimeTool:costTime(second_)
	return string.format("%02d:%02d:%02d", math.floor(second_/3600), math.floor((second_%3600)/60), math.floor(second_%60))
end

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326448278&siteId=291194637