> 日期的常用寫法特此介紹
[TOC]
## 初始化
~~~
new Date(); // 默認當前時間
new Date(value); // 時間戳參數。毫秒,可使用new Date().getTime()獲取時間戳
new Date(dateString); // 時間字符串
~~~
## 格式化
~~~
var date = new Date();
console.log(formatDate(date))
// 日期格式化封裝
function formatDate(date){
return date.getFullYear()+'-'+(date.getMonth()+1).toString()+"-"+date.getDate()+' '+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()
}
~~~