js获取系统当前时间
CreateTime--2018年2月7日11:04:16
Author:Marydon
/** * 获取系统当前时间并格式化 * @returns yyyy-MM-dd HH:mm:ss */function getCurrentFormatDate() { ???// 系统当前时间格式化 ???var currentFormatDate = ""; ???// 获取系统当前日期 ???var date = new Date(); ???// 获取当前年 ???var currentYear = date.getFullYear(); ???// 获取当前月 ???var currentMonth = date.getMonth() + 1; ???// 获取当前日 ???var currentDay = date.getDate(); ???// 时 ???var currentHours = date.getHours(); ???// 分 ???var currentMinutes = date.getMinutes(); ???// 秒 ???var currentSeconds = date.getSeconds(); ???????// 格式化 ???if (currentMonth >= 1 && currentMonth <= 9) { ???????currentMonth = "0" + currentMonth; ???} ???????if (currentDay >= 0 && currentDay <= 9) { ???????currentDay = "0" + currentDay; ???} ???currentFormatDate = currentYear + "-" + currentMonth + "-" + currentDay + " " + currentHours + ":" + currentMinutes ???????????+ ":" + currentSeconds; ???return currentFormatDate;}
js 获取系统当前时间
原文地址:https://www.cnblogs.com/Marydon20170307/p/8425667.html