คัดลอกรหัสรหัสดังนี้:
-
* การกำหนดวัตถุเวลา;
-
date.prototype.format = function (รูปแบบ) {
-
* เช่น: format = "yyyy-mm-dd hh: mm: ss";
-
var o = {
"M +": this.getMonth () + 1, // เดือน
"d+": this.getdate (), // วัน
"H+": this.getHours (), // ชั่วโมง
"M+": this.getMinutes (), // นาที
"S+": this.getSeconds (), // วินาที
"Q +": Math.floor ((this.getMonth ()) + 3), // quarter
"s": this.getmilliseconds ()
// มิลลิวินาที
-
if (//y+)/.test (รูปแบบ)) {{
format = format.replace (regexp. $ 1, (this.getlyear () + "")
.substr (4 -regexp. $ 1. ความยาว);
-
สำหรับ (var k ใน o) {
if (ใหม่ regexp ("(" + k + ")") การทดสอบ (รูปแบบ) {
format = format.replace (regexp. $ 1, regexp. $ 1. ความยาว == 1? o [k]
: ("00" + o [k])
-
-
รูปแบบการส่งคืน;
-
คัดลอกรหัสรหัสดังนี้:
var now = new Date ()
คัดลอกรหัสรหัสดังนี้:
วันที่ใหม่ ()