Javascript Date Get Methods

These methods can be used for getting information from a date object:

Эдгээр аргуудыг огнооны объектоос мэдээлэл авахад ашиглаж болно:

 
Method Description
getFullYear() Get the year as a four digit number (yyyy)

Жилийг дөрвөн оронтой тоогоор авна уу (yyyy)

getMonth() Get the month as a number (0-11)

Сарыг тоогоор авна уу (0-11)

getDate() Get the day as a number (1-31)

Өдрийг тоогоор авна уу (1-31)

getHours() Get the hour (0-23)

Цаг авах (0-23)

getMinutes() Get the minute (0-59)

Минут ав (0-59)

getSeconds() Get the second (0-59)

Хоёр дахь хэсгийг аваарай (0-59)

getMilliseconds() Get the millisecond (0-999)

Милисекунд авах (0-999)

getTime() Get the time (milliseconds since January 1, 1970)

Цаг авах (1970 оны 1-р сарын 1-ээс хойш миллисекунд)

getDay() Get the weekday as a number (0-6)

Ажлын өдрийг тоогоор авна уу (0-6)

Date.now() Get the time. ECMAScript 5.

Цаг гаргах. ECMAScript 5.


The getTime() Method #

The getTime() method returns the number of milliseconds since January 1, 1970:

GetTime () арга нь 1970 оны 1-р сарын 1-ээс хойш миллисекундийн тоог буцаана:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getTime();

The getFullYear() Method #

The getFullYear() method returns the year of a date as a four digit number:

getFullYear() арга нь огнооны жилийг дөрвөн оронтой тоогоор буцаана:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getFullYear();

The getMonth() Method #

The getMonth() method returns the month of a date as a number (0-11):

getMonth() арга нь огнооны сарыг тоогоор (0-11) буцаадаг:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getMonth();

In JavaScript, the first month (January) is month number 0, so December returns month number 11.

JavaScript дээр эхний сар (1-р сар) нь 0-р сарын дугаар тул 12-р сар нь 11-р сарыг буцаана.

You can use an array of names, and getMonth() to return the month as a name:

Та нэрний багцыг ашиглаж, getMonth () -ыг сар болгон нэрээр нь буцааж өгөх боломжтой.

Example Жишээ #

var d = new Date(); var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; document.getElementById("demo").innerHTML = months[d.getMonth()];

The getDate() Method #

The getDate() method returns the day of a date as a number (1-31):

getDate() арга нь огнооны өдрийг тоогоор (1-31) буцаадаг:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getDate();

The getHours() Method #

The getHours() method returns the hours of a date as a number (0-23):

getHours() арга нь огнооны цагийг тоогоор (0-23) буцаадаг:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getHours();

The getMinutes() Method #

The getMinutes() method returns the minutes of a date as a number (0-59):

getMinutes() арга нь огнооны минутыг тоогоор (0-59) буцаадаг:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getMinutes();

The getSeconds() Method #

The getSeconds() method returns the seconds of a date as a number (0-59):

getSeconds() арга нь огнооны секундийг тоогоор (0-59) буцаадаг:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getSeconds();

The getMilliseconds() Method #

The getMilliseconds() method returns the milliseconds of a date as a number (0-999):

getMilliseconds() арга нь огнооны миллисекундийг (0-999) тоогоор буцаана:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getMilliseconds();

The getDay() Method #

The getDay() method returns the weekday of a date as a number (0-6):

getDay() арга нь огнооны ажлын өдрийг (0-6) тоогоор буцаана:

Example Жишээ #

var d = new Date(); document.getElementById("demo").innerHTML = d.getDay();

In JavaScript, the first day of the week (0) means “Sunday”, even if some countries in the world consider the first day of the week to be “Monday”

JavaScript дээр дэлхийн зарим улс орнууд долоо хоногийн эхний өдрийг “даваа гараг” гэж үздэг байсан ч гэсэн долоо хоногийн эхний өдөр (0) “ням гараг” гэсэн утгатай.

You can use an array of names, and getDay() to return the weekday as a name:

Та нэрний багцыг ашиглаж, ажлын өдрийг нэр болгон буцааж авахын тулд getDay() -г ашиглаж болно.

Example Жишээ #

var d = new Date(); var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; document.getElementById("demo").innerHTML = days[d.getDay()];

UTC Date Methods #

UTC date methods are used for working with UTC dates (Universal Time Zone dates):

UTC огнооны аргуудыг UTC огноотой ажиллахад ашигладаг (Дэлхийн цагийн бүсийн огноо):

Method Description
getUTCDate() Same as getDate(), but returns the UTC date

GetDate () -тай ижил боловч UTC огноог буцаана

getUTCDay() Same as getDay(), but returns the UTC day

GetDay () -тай ижил боловч UTC-ийн өдрийг буцаана

getUTCFullYear() Same as getFullYear(), but returns the UTC year

GetFullYear () -тай ижил боловч UTC оныг буцаана

getUTCHours() Same as getHours(), but returns the UTC hour

GetHours () -тай ижил боловч UTC цагийг буцаана

getUTCMilliseconds() Same as getMilliseconds(), but returns the UTC milliseconds

GetMilliseconds () -тэй ижил боловч UTC миллисекундийг буцаана

getUTCMinutes() Same as getMinutes(), but returns the UTC minutes

GetMinutes () -тай ижил боловч UTC минутыг буцаана

getUTCMonth() Same as getMonth(), but returns the UTC month

GetMonth () -тай ижил боловч UTC сарыг буцаана

getUTCSeconds() Same as getSeconds(), but returns the UTC seconds

GetSeconds () -тай ижил боловч UTC секундийг буцаана


Complete JavaScript Date Reference #

Бүрэн Javascript огнооны лавлагаа #

For a complete reference, go to our Complete JavaScript Date Reference.

Бүрэн лавлагаа авахын тулд манай Бүрэн Javascript Date Reference руу орно уу.

The reference contains descriptions and examples of all Date properties and methods.

Лавлагаа нь огнооны бүх шинж чанар, аргын тодорхойлолт, жишээг агуулдаг.

Powered by BetterDocs

Leave a Reply