JavaScript Date.UTC()
ဥပမာ
ရက်စွဲတစ်ခုနှင့် ဇန်နဝါရီလ 1၊ 1970 ခုနှစ်အကြား မီလီစက္ကန့်အရေအတွက်ကို ရယူပါ-
let ms = Date.UTC(2020, 02, 30);
အောက်တွင် နောက်ထပ် "စမ်းသုံးကြည့်ပါ" ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
UTC အရ Date.UTC() နည်းလမ်းသည် သတ်မှတ်ထားသောရက်စွဲနှင့် 1970 ခုနှစ် ဇန်နဝါရီလ 1 ရက်နေ့ သန်းခေါင်ယံကြားတွင် မီလီစက္ကန့်အရေအတွက်ကို ပြန်ပေးသည်။
မှတ်စုများ
UTC (Universal Time Coordinated) သည် World Time Standard မှ သတ်မှတ်ထားသော အချိန်ဖြစ်သည်။
UTC အချိန်သည် GMT အချိန် (Greenwich Mean Time) နှင့် တူညီသည်။
Browser ပံ့ပိုးမှု
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() သည် Date object ၏ static method တစ်ခုဖြစ်သည်။
d.UTC() ကဲ့သို့ ရက်စွဲတစ်ခုတွင် သင်သည် ၎င်းကို အသုံးမပြုနိုင်ပါ။
syntax သည် အမြဲတမ်း 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 ၁ |
နောက်ထပ် ဥပမာများ
ဥပမာ
ဒေသစံတော်ချိန်အစား UTC အချိန်ကို အသုံးပြု၍ ရက်စွဲအရာဝတ္ထုတစ်ခုကို ဖန်တီးပါ-
let d = new Date(Date.UTC(2020, 02, 30));