JavaScript Date.UTC ()
مثال
احصل على عدد المللي ثانية بين تاريخ و 1 يناير 1970:
let ms = Date.UTC(2020, 02, 30);
المزيد من الأمثلة "جربها بنفسك" أدناه.
التعريف والاستخدام
ترجع طريقة Date.UTC () عدد المللي ثانية بين تاريخ محدد ومنتصف ليل الأول من يناير 1970 ، وفقًا للتوقيت العالمي المنسق (UTC).
ملحوظات
UTC (تنسيق التوقيت العالمي) هو الوقت الذي يحدده معيار التوقيت العالمي.
التوقيت العالمي المنسق (UTC) هو نفس توقيت غرينتش (توقيت غرينتش).
دعم المتصفح
Date.UTC()
هي إحدى ميزات ECMAScript1 (ES1).
ES1 (JavaScript 1997) مدعوم بالكامل في جميع المتصفحات:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
بناء الجملة
Date.UTC(year, month, day, hours, minutes, seconds, millisec)
Date.UTC () هي طريقة ثابتة لكائن التاريخ.
لا يمكنك استخدامه في تاريخ مثل d.UTC ()
يكون بناء الجملة دائمًا Date.UTC ().
قيمه المعامل
Parameter | Description |
---|---|
year | Required. A four-digit value representing the year, negative values are allowed |
month | Required. An integer representing the month
Expected values are 0-11, but other values are allowed:
|
day | Optional. An integer representing the day of month
Expected values are 1-31, but other values are allowed:
If the month has 31 days:
If the month has 30 days:
|
hour | Optional. Default 0. An integer representing the hour.
Expected values are 0-23, but other values are allowed:
|
min | Optional. Default 0. An integer representing the minutes.
Expected values are 0-59, but other values are allowed:
|
sec | Optional. Default 0. An integer representing the seconds
Expected values are 0-59, but other values are allowed:
|
millisec | Optional. Default 0. An integer representing the milliseconds
Expected values are 0-999, but other values are allowed:
|
تفاصيل تقنية
قيمة الإرجاع: | رقم يمثل عدد المللي ثانية بين التاريخ والوقت المحدد ومنتصف ليل 1 يناير 1970 |
---|---|
إصدار JavaScript: | ECMAScript 1 |
مزيد من الأمثلة
مثال
قم بإنشاء كائن تاريخ باستخدام التوقيت العالمي المنسق (UTC) بدلاً من التوقيت المحلي:
let d = new Date(Date.UTC(2020, 02, 30));