Write about date object in Java Script
https://www.computersprofessor.com/2019/05/write-about-date-object-in-java-script.html
date object:
java script includes a well defined date class which provides functions to
perform many different date manipulations.
In java script date and times represents the
number of milli seconds since 1st January,1970 UTC. Java script represent time
in UTC and local notations.
UTC
is Universal time, Local time is the time on the machine In which the script is
executing. A java script date object can represents date from -100,000,000 to
+100,000,000 days relative to 01/01/1970.
Java script date functions:
To
illustrate date functions define a variable vardt= new date();
Method
|
Description
|
Example
|
date()
|
Returns the current and time
|
vardt=date();
|
get Date()
|
Returns date between the days of 1 & 31
|
dt.getDate();
|
get Day()
|
Returns the day of the week, numbered 0 to 6
|
dt.getDay();
|
get FullYear()
|
Returns the year as a four digit number
|
dt.getFullYear();
|
getYear()
|
Returns the year as a 2 digit number
|
dt.getYear();
|
getHours()
|
Returns the current hour from 0 to 23
|
dt.getHour();
|
getMinutes()
|
Returns the current minutes from 0 to 59
|
dt.getMinutes();
|
getSeconds()
|
Returns the current seconds from 0 to 59
|
dt.getSeconds();
|
getMilliseconds()
|
Returns the current milliseconds from 0 to 999
|
dt.getMilliseconds();
|
getTime()
|
Returns the milliseconds since January 1,1970
|
dt.getTime();
|
setDate()
|
Specifies the day of the month
From 1 to 31
|
dt.setDate(3);
|
setMonth()
|
Specifies the month from 0 to 11
|
dt.setMonth(4);
|
setHours()
|
Specifies the hour of a day
|
dt.setHour(5);
|
setSeconds()
|
Specifies the seconds of the date object
|
dt.setSeconds(6);
|
getUTCDay()
|
Returns the day of
the week, according to universal time (from 0-6)
|
dt.getUTCDay();
|
Returns the year, according to universal time
|
||
Returns the hour, according to universal time (from
0-23)
|
||
Returns the milliseconds, according to universal time
(from 0-999)
|
||
Returns the minutes, according to universal time (from
0-59)
|
||
Returns the month, according to universal time (from
0-11)
|