js转换方法
2012-06-07 17:28:47 来源:WEB开发网核心提示://将秒转成中文描述,130转为2分钟10秒function formatTime(timeInSeconds){ var seconds = Math.floor(timeInSeconds); var minutes = Math.floor(timeInSeconds / 60.0); var
//将秒转成中文描述,130转为2分钟10秒 function formatTime(timeInSeconds){ var seconds = Math.floor(timeInSeconds); var minutes = Math.floor(timeInSeconds / 60.0); var hours = Math.floor(minutes / 60.0); if (hours != 0) { return hours + "小时 " + (minutes % 60) + "分钟 " + (seconds % 60) + "秒"; } if (minutes % 60 != 0) { return minutes % 60 + "分钟 " + (seconds % 60) + "秒"; } else { return seconds % 60 + " 秒"; } } //流量或容量转 function fsize(flong){ if (flong <= 0) { return "";} else if (flong < 1024) { return flong + "bytes"; } else if (flong < 1024 * 1024) { var fm = Math.floor(flong / 1024); return fm + "K"; } else if (flong < 1024 * 1024 * 1024) { var fm = Math.floor(flong / (1024 * 1024)); return fm + "M"; } else if (flong < 1024 * 1024 * 1024 * 1024) { var fm = Math.floor(flong / (1024 * 1024 * 1024)); return fm + "M"; } }
赞助商链接