js格式化時間和js格式化時間戳示例
/**
* 時間對象的格式化;
*/
Date.prototype.format = function(format) {
/*
* eg:format="YYYY-MM-dd hh:mm:ss";
*/
var o = {
"M+" :this.getMonth() + 1, // month
"d+" :this.getDate(), // day
"h+" :this.getHours(), // hour
"m+" :this.getMinutes(), // minute
"s+" :this.getSeconds(), // second
"q+" :Math.floor((this.getMonth() + 3) / 3), // quarter
"S" :this.getMilliseconds()
// millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "")
.substr(4 - RegExp.$1.length));
}
for ( var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
: ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
}
var now = new Date().format("yyyy-MM-dd hh:mm:ss");
new Date().format("yy-MM-dd hh:mm");
- js時間戳轉(zhuǎn)為日期格式的方法
- JavaScript 獲取當前時間戳的代碼
- js時間戳與日期格式之間相互轉(zhuǎn)換
- javascript時間戳和日期字符串相互轉(zhuǎn)換代碼(超簡單)
- js時間戳格式化成日期格式的多種方法
- js 時間格式與時間戳的相互轉(zhuǎn)換示例代碼
- JS獲取當前時間戳方法解析
- JS獲取時間的相關(guān)函數(shù)及時間戳與時間日期之間的轉(zhuǎn)換
- nodejs如何獲取時間戳與時間差
- Vue.js 時間轉(zhuǎn)換代碼及時間戳轉(zhuǎn)時間字符串
- js獲取時間并實現(xiàn)字符串和時間戳之間的轉(zhuǎn)換
- 時間戳轉(zhuǎn)換為時間 年月日時間的JS函數(shù)
- js實現(xiàn)把時間戳轉(zhuǎn)換為yyyy-MM-dd hh:mm 格式(es6語法)
- Javascript new Date().valueOf()的作用與時間戳由來詳解
- JavaScript時間戳與時間日期間相互轉(zhuǎn)換
- jsp頁面中如何將時間戳字符串格式化為時間標簽
- javascript日期轉(zhuǎn)換 時間戳轉(zhuǎn)日期格式
- js中?new?Date().getTime()得到的是毫秒數(shù)時間戳
相關(guān)文章
在firefox和Chrome下關(guān)閉瀏覽器窗口無效的解決方法
首先IE是可以通過window.close()來關(guān)閉瀏覽器窗口的,但是在firefox和Chrome下是無效的,但是可以通過一些特殊的手段進行關(guān)閉2014-01-01

