JS获取(格式化)系统当前时间
2017-03-11 16:15
447 查看
下面这个方法不错的
var getNowFormatDate=function() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
var getNowFormatDate=function() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
相关文章推荐
- JS获取系统当前时间并格式化输出小函数
- JS取得当前系统时间并且格式化
- Js获取当前日期时间及格式化操作
- js实时获取系统当前时间实例代码
- JS之Date对象和获取系统当前时间
- js获取当前系统时间
- js 获取当前时间并格式化
- js实时获取系统当前时间实例代码
- js动态获取当前系统时间+js字符串转换为date日期对象
- JAVA中获取当前系统时间,日期并格式化输出
- js获取当前系统时间
- js获取系统当前时间
- java中获取当前系统时间,日期并格式化输出
- js获取系统当前时间
- js获取当前时间以及日期格式化
- js获取系统当前时间
- js 设置获取当前时间后30 的日期,并格式化
- js 时间格式化 获取当前时间
- java中获取当前系统时间,日期并格式化输出
- JS之Date对象和获取系统当前时间详解