Javascript Dates

Javascript Dates

Javascript Dates object provides a lot of methods for manipulating date and times. JavaScript stores dates internally as the number of millisecond. Days of the week and months always started with zero.

Date() method is a powerful method

We have many syntax of date method.

 

var test=new Date();

Use of  ” month dd,  yyyy,  hh.mm.ss ” create object with the date represented by the month,  day (dd) ,

year (yyyy) , hour (hh) , minute(mm) , and second (ss).

Example :  var test=new Date(“june 16, 1989”);

millisecond :  Creates object with date represented as the integer number of milliseconds .

 

Example :  var test=new Date(895696325896);

Use of yyyy , mm ,  dd  : –  Create object with the date specified by the integer values year (yyyy) ,

month (mm) ,  and  day(dd).

 

Use of  ” yyyy ,  mm ,  dd ,  hh , mm , ss  ” .  Creates Object with the date specified by the integer values

for the year ,  month ,  day ,  hours ,  minutes  ,  and second.

Example  :  var test =  new Date(1980,6,17,13,0,0);

 

Use of  ”  yyyy ,  mm ,  dd ,  hh ,  mm ,  ss , ms  “.  Create object with the date specified by the integer values.

for the year ,  month ,  day ,  hours ,  seconds , and milliseconds.

Example : –  var test = new Date(1980 , 6 , 17 , 17 , 0 , 260);

 

Example :-

var  first = new Date( 1996 , 0 , 7 );

var second = new Date( 2017 , 11 , 4);

var substract = second – first;

alert ( substract );

 




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top