获取当前时间:格式如’2017-09-08 8:30:00’
2017-08-17 11:33
288 查看
原文来自:http://www.cnblogs.com/hanwenhua/articles/3853352.html
getNowFormatDate() {
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 new Date(currentdate).getTime();
}
getNowFormatDate() {
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 new Date(currentdate).getTime();
}
相关文章推荐
- iOS 获取当前时间,并按照要求格式显示
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- asp.net获取当前时间自定义格式小窍门
- PHP获取当前时间、时间戳的各种格式写法汇总
- 创建一个Date.text文件,获取当前的日期,将日期格式为“2013/02/14 05:20:00”的形式。然后一秒钟记录一次,将新的时间存入到文件中。
- C#中获取计算机当前日期时间等的不同格式
- js 获取当前日期时间 格式为 yyyy-mm-dd hh:MM:ss
- js 获取当前日期时间 格式为 yyyy-mm-dd hh:MM:ss
- 【转】PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- 使用js时,如何获取系统当前时间并且得到格式为"yyyy年MM月"的日期
- 获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS"
- C++如何获取当前时间并转换成相应的格式字符串.
- 获取当前时间并转换格式
- 获取当前的时间,转化为char[]格式unix时间戳
- 在C++中获取当前时间并转换为可读时间格式(Win32和Linux通用)
- js 字符串转时间格式,js 获取当前时间
- js获取当前时间转换时间格式yyyy-mm-dd hh:mm:ss
- Windows 驱动:获取系统当前时间,生成格式字符串
- js获取当前时间与传入的时间进行比较 格式yyyy-MM-dd hh:mm:ss
- Object-C获取系统当前时间(指定格式)