1、js获取当前日期时间转化成 yyyy/mm/dd hh:mm:ss
function currentTime(){
var date = new Date();
var f1 = "/";
var f2 = ":";
var month = date.getMonth() + 1;
var date = date.getDate();
if(month >= 1 && month <= 9) {
month = "0" +month;
}
if(date >= 0 && date <= 9) {
date = "0" + date;
}
var currentdate = date.getFullYear() + f1 +month + f1 + date + " " + date.getHours() + f2 + date.getMinutes() + f2 + date.getSeconds();
return currentdate;
}
2、yyyy/mm/dd
function getNowDate(){
var date = new Date();
var f1 = "/";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var date = date.getDate();
if(month >= 1 && month <= 9){
month = "0" + month;
}
if(date >= 0 && date <= 9){
date = "0" + date;
}
var currentdate = year + f1 + month + f1 + date;
return currentdate;
}