วันที่ JavaScript getUTCM มิลลิวินาที ()
ตัวอย่าง
รับ UTC มิลลิวินาที:
const d = new Date();
let ms = d.getUTCMilliseconds();
รับ UTC มิลลิวินาทีจากวันที่ระบุ:
const d = new Date("July 21, 1983 01:15:00:195");
let ms = d.getUTCMilliseconds();
ตัวอย่างเพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
getUTCMilliseconds()
ส่งกลับมิลลิวินาที (0 ถึง 999) ของวันที่
getUTCMilliseconds()
ส่งกลับมิลลิวินาทีตาม UTC
หมายเหตุ
UTC (Universal Time Coordinated) คือเวลาที่กำหนดโดยมาตรฐานเวลาโลก
เวลา UTC จะเหมือนกับเวลา GMT (เวลามาตรฐานกรีนิช)
วิธี JavaScript getUTC ทั้งหมดถือว่าวันที่เป็นเวลาท้องถิ่น
ไวยากรณ์
Date.getUTCMilliseconds()
พารามิเตอร์
ไม่มี |
คืนมูลค่า
พิมพ์ | คำอธิบาย |
หมายเลข | มิลลิวินาทีของวันที่ (0 ถึง 999) |
รองรับเบราว์เซอร์
getUTCMilliseconds()
เป็นคุณลักษณะ ECMAScript1 (ES1)
ES1 (JavaScript 1997) ได้รับการสนับสนุนอย่างสมบูรณ์ในเบราว์เซอร์ทั้งหมด:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
ตัวอย่างเพิ่มเติม
ใช้เมธอด getUTC ทั้งหมดเพื่อแสดงเวลาสากล:
function addZero(x, n) {
while (x.toString().length < n) {
x = "0" + x;
}
return x;
}
const d = new Date();
let h = addZero(d.getUTCHours());
let m = addZero(d.getUTCMinutes());
let s = addZero(d.getUTCSeconds());
let ms = addZero(d.getUTCMilliseconds());
let time = h + ":" + m + ":" + s;