將標準時間轉換為某種時間的格式
function formatDate() {
var today = new Date();
return today.toLocaleString("zh-Hans-CN", {
// timeZone: ['UTC'],
weekday: "long",
hour12: false,
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
}輸出2018年06月27日星期三 10:09:19 function showingExpirationDate() {
var today = new Date();
return today.toISOString().substring(0,10)+ ' '+today.toTimeString().substring(0,9);
}輸出 2018-06-27 10:07:02複製程式碼
http://www.imooc.com/wenda/detail/395292