转换时间格式(年月日时分秒)
/**
* 格式化秒
* @param int value 总秒数
* @return string result 格式化后的字符串
*/
function formatSeconds(value) {
var theTime = parseInt(value);// 需要转换的时间秒
var theTime1 = 0;// 分
var theTime2 = 0;// 小时
var theTime3 = 0;// 天
if(theTime > 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime%60);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1%60);
if(theTime2 > 24){
//大于24小时
theTime3 = parseInt(theTime2/24);
theTime2 = parseInt(theTime2%24);
}
}
}
var result = '';
if(theTime > 0){
result = ""+parseInt(theTime)+"秒";
}
if(theTime1 > 0) {
result = ""+parseInt(theTime1)+"分"+result;
}
if(theTime2 > 0) {
result = ""+parseInt(theTime2)+"小时"+result;
}
if(theTime3 > 0) {
result = ""+parseInt(theTime3)+"天"+result;
}
return result;
}
转换时间格式(年月日时分秒)相关推荐
- java时间格式年月日时分秒_java日期格式(年月日时分秒毫秒)
java日期格式(年月日时分秒毫秒) 2020-08-13 07:09 阅读数 79 package test.remote.tools.combine; import java.text.Simpl ...
- 时间格式 年月日时分秒毫秒
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String time = for ...
- Java日期转换 SimpleDateFormat格式(年月日时分秒)
24小时制时间显示: import java.util.Date; public class DateTest { /** * @param args */ public static void ma ...
- Android 时间格式 年月日时分秒毫秒
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String time = ...
- android获取年月日时分秒毫秒,Android获取两个日期其间间隔的天数
/** * 获取两个日期之间的间隔天数 * @return */ public static int getGapCount(Date startDate, Date endDate) { Calen ...
- 将时间戳“年月日 时分秒”格式转换成“年月日”格式
将时间戳"年月日 时分秒"格式转换成"年月日"格式 将时间戳"年月日 时分秒"格式转换成"年月日"格式 总是忘记要重新查 ...
- java年月日时分秒格式_Java 日期时间 LocalDate LocalTime LocalDateTime类
// LoacalDate, LocalTime, LocalDateTime类// 不要使用构造器来构造LocalDate类的对象.实际上,应该使用LocalDate.now()静态工厂方法代表你调 ...
- js如何将时间的标准格式和时间戳格式和2022-01-27 00:00:00(年月日时分秒)格式相互转换
目录 前言 一.new Date()? 1. new Date() 是什么? 2. 怎么用? 二.格式化工具函数 1.如何调用函数: 2.代码如下(示例): 总结 前言 这里主要讲的是如何将我们的在项 ...
- sql里面如何将年月日时分秒的格式转换成年月日
例如 我需要通过 取到数据库中的 原有数据是年月日时分秒格式的,目前需要转换成年月日 此时需要 使用一个关键字 ------DATE_FORMAT(clue_create_time,'%Y-%m-% ...
- python中年月日时分秒格式
python的 年月日时分秒 datetime import datetime date = datetime.datetime.today() print(date) datetime.dateti ...
最新文章
- Linux系统文件类型
- 计算机教案制作电子表格,人教版七年级信息技术上册《制作电子表格》教案
- a1278 win10声卡驱动_windows安装系列教程—驱动安装
- minheight能继承吗_CSS 哪些属性默认会继承, 哪些不会继承?
- GCD学习之dispatch_barrier_async
- 分布式系统部署、监控与进程管理的几重境界
- grasshopper_如何使用Google的Grasshopper编码应用程序来学习手机上的编码基础知识...
- html新增伪类,css3新增伪类有哪些
- ASP.NET 安全性
- 使用idea创建项目并通过git上传到码云
- Spring Boot整合 Thymeleaf 模板引擎
- php中的date()函数d y m l等字母的表示方法
- html界面嵌入网易云,使用flex进行网易云音乐界面构建和布局解析(1)
- Activiti6教程一
- 《金字塔原理》学习笔记 | 第1篇—表达的逻辑
- 非华为电脑安装华为电脑管家
- 前后端分离架构设计(权限模型)
- 微信小程序开发之——仿微信视频录制上传
- javascript匿名函数传值问题
- HTML a 标签的 href 属性
热门文章
- 反汇编专用工具——objdump
- CentOS 6.5下搭建Maven私服nexus
- [xbttracker] linux 下 xbt tracker环境搭建(ubuntu)
- Nginx服务之监控模块vts
- 会声会影2018、2019版启动提示未注册的解决方法
- 基于springboot线上买菜系统
- Solidworks输出1:1图纸DWG格式文件参数设置
- 模拟3d星空python_python模拟3D星空动画turtle版右出
- 小米9什么时间升级android10,小米9/MIX 3 现在即可升级安卓10.0!升级指南戳这里...
- 舒心花了6分钟快速入门Liunx