Thursday, September 13, 2018

JavaScript - Built in Functions - Date Object

Date object is another important built in Object in JavaScript. Check out the following examples:

var currDate = new Date();
console.log(currDate.toString());

var specificDate = new Date(2018,14,1);
console.log(specificDate.toString());

var specificDate = new Date('2018/10/1');
console.log(specificDate.toString());

console.log(Date.parse('2018/10/1'));
console.log(currDate.getDate());
console.log(currDate.getDay());


Console Output:

  • "Thu Sep 13 2018 06:20:34 GMT+0530 (India Standard Time)"
  • "Fri Mar 01 2019 00:00:00 GMT+0530 (India Standard Time)"
  • "Mon Oct 01 2018 00:00:00 GMT+0530 (India Standard Time)"
  • 1538332200000
  • 13
  • 4



Practice at:




Refer:



No comments:

Post a Comment