91-9990449935 0120-4256464 |
JavaScript Date ObjectThe JavaScript date object can be used to get year, month and day. You can display a timer on the webpage by the help of JavaScript date object. You can use different Date constructors to create date object. It provides methods to get and set day, month, year, hour, minute and seconds. ConstructorYou can use 4 variant of Date constructor to create date object. JavaScript Date MethodsThe important methods of date object are as follows:
JavaScript Date ExampleLet's see the simple example to print date object. It prints date and time both. Test it NowOutput:
Current Date and Time:
JavaScript Current Time ExampleLet's see the simple example to print current time of system. Test it NowOutput:
Current Time:
JavaScript Digital Clock ExampleLet's see the simple example to display digital clock using JavaScript date object. There are two ways to set interval in JavaScript: by setTimeout() or setInterval() method. Test it NowOutput:
Current Time:
Next TopicJavaScript Math Object
|