Javascript时间以及格式化秒
来源:互联网 发布:电饼铛品牌 知乎 编辑:程序博客网 时间:2024/05/22 14:05
var now = new Date();
timer = $.timer(timeout, function () {
var sec_num = Math.ceil((now.getTime() - startTime.getTime()) / 1000);
showPaperTimer(now, sec_num);
if (sec_num % 60 == 0) {
}
});
function showPaperTimer(now, sec_num) {
var nowStr = now.getFullYear() + '-';
nowStr += now.getMonth() + 1 + '-';
nowStr += now.getDate() + ' ';
nowStr += now.getHours() + ':';
nowStr += now.getMinutes() + ':';
nowStr += now.getSeconds();
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) { hours = "0" + hours; }
if (minutes < 10) { minutes = "0" + minutes; }
if (seconds < 10) { seconds = "0" + seconds; }
var time0 = hours + ':' + minutes + ':' + seconds;
$("#times").html("当前时间:" + str + ",已耗时:" + time0);
}
其中,$.timer是一个Jq时钟,来自于http://plugins.jquery.com/timer/,其常用操作有:
var timeout = 1000;
var timer;
$("input[name=start]").click(function() {
$("#console").append("<span style=\"color: #0F0\">Timer started.</span<br />");
timer = $.timer(timeout, function() {
$("#console").append("Timer completed.<br />");
});
});
$("input[name=stop]").click(function() {
if(timer.stop()) {
$("#console").append("<span style=\"color: #F00\">Timer stopped.</span<br />");
}
});
$("input[name=pause]").click(function() {
if(timer.pause()) {
$("#console").append("<span style=\"color: #FF0\">Timer paused.</span<br />");
}
});
$("input[name=resume]").click(function() {
if(timer.resume()) {
$("#console").append("<span style=\"color: #F00\">Timer resumed.</span<br />");
}
});
$("input[name=reset]").click(function() {
timer.stop();
timeout = prompt("Reset timeout too:", 500);
timer.reset(timeout);
$("#console").append("<span style=\"color: #00F\">Timer reset.</span<br />");
});
- Javascript时间以及格式化秒
- 时间的格式化(秒化分秒)
- js(javascript)取得当前时间小时,分钟,秒 以及毫秒
- js(javascript)取得当前时间小时,分钟,秒 以及毫秒
- js获取当前时间的年月日时分秒以及时间的格式化
- 时间,日期格式化以及 格式化时间戳
- 时间获取以及时间格式化
- javascript格式化时间
- javascript格式化时间
- JavaScript 格式化时间日期
- javascript格式化时间输出
- javascript:时间格式化
- Javascript 日期时间格式化
- javascript格式化时间
- Javascript 日期时间格式化
- JavaScript格式化时间
- javascript日期时间格式化
- JavaScript格式化时间
- EasyUI Datagrid 自定义列、Foolter及单元格编辑
- Hadoop 入门
- C#和Javascript间互转的Xxtea加解密
- 过于细的计划是空的
- Javascript数组操作及索引
- Javascript时间以及格式化秒
- 跨库查询(OpenDataSource)与链接服务器(Linking Server)
- Leader之重
- Eclipse无法启动(一闪而过)的解决方法
- e4 技术白皮书
- [DataContract](数据契约)与[DataMember]
- 万里长征,始于足下——菜鸟程序员的学习总结(三)
- windows server2008 IE 普通用户(非管理员用户)不能进行安全配置
- IOS成长之路-MD5加密算法