In C-SharpCorner Delhi Chapter meet up we
enjoyed JavaScript with Fun and Knowledge. There was a lot of knowledge with
C-Sharp corner Team. Here they covered many topics of JavaScript Like: Object,
Array, function, methods with live practical. In front of 120+ audiences Speaker
was Dhananjay Kumar, Brij Mishra and Suchit Khanna. Here you can learn
JavaScript next and next to next month too, So stay tune with C-SharpCorner
Updates.
After learning a lot more Now Let's Start a new topic : Date objects in
JavaScript Objects.
The object is used to display a date on web page or a timestamp in numerical or
in any mathematical calculation. In JavaScript, we can either define the Date
object by providing the date of our choice or let JavaScript define the Date
object based on the visitor's System clock. The Date object stores dates as
milliseconds that have passed since midnight on January 1, 1970 Universal Time
Code(UTC). The Date object can represent dates before 285,616 years before or
after January 1, 1970. The Date object can be created with the help of the
constructor function.
We can follow the given Syntax for making Data object. :
We can follow these above lines for making a Date object.
There are two properties of the Date object :
And Many methods (Like- getDate(), getDay(), getUTCDate(), Parse(), setMonth(),
UTC(), valueOf()………..Etc) are in JavaScript.
Now let's do an Example:
Print the Date and Time of your own System. Follow the given Code-
Script is given in the Red Box. In given Code Data object name mydate is created
by using new keyword. The date is fetched by using three methods : getDate(),
getMonth() and getFullyear(). The getDate() method retrieves the current date of
the month. The getMonth() retrieves the current numerical equivalence of the
month, Which in
0 for January
1 for February,
2 for March
4 for March and Similar for Others.
The getFullYear() method is used to get the current year.
The current time is retrieved by three methods getHours(), getMinutes() and
getSeconds(). The getHours() method is used to retrieve the current hour, which
comes in the range 0 t0 23. The getMinutes() method is used to retrieve the
current minute that ranges from o to 59. The getSeconds() method is used to
retrieve the second of the current time that ranges from 0 to 59.
Now let's see the output of the given Code for My System:
Do more Exercise, be more perfect.