Date set and get the js

js acquired first time to time need to create objects: syntax var oDate = new Date ();

Get the current time

  getHours Gets the current number of hours
  getMinutes get the current number of minutes
  getSeconds get the current number of seconds

 

Gets the current time period

  Year 4-digit acquired; getFullYear ()

   getMonth (); Gets month, starting from 0, 0 for January  

  getDate (); Gets the number of days in the month  

  getDay (); obtaining a week, starting from 0 the getMilliseconds (); Get the current number of milliseconds  

  getTime (); Gets the number of milliseconds from January 1, 1970 to the present

 

Different methods of setting time

 new Date (time); time from January 1, 1970 to set the time of milliseconds
   new new a Date ( 'May 25, 2004');
   new new a Date (2011,1,1); 2011 Nian 2 Yue 1 Ri

 Set 4 digit year; the setFullYear ()

  setMonth (); set the month, starting at 0, 0 for January

  setDate (); the number of days in the month setDay set (); setting of the week, starting from 0

  setHours (); set the current number of hours, 0-23

  the setMinutes (); set the current minutes, 0-59  

 the setSeconds (); set the current number of seconds, 0-59  

 to setMilliseconds (); set the current number of milliseconds  

 setTime (); setting from 1 January 1970 to the current number of milliseconds

 

 

 

 

Reproduced in: https: //www.cnblogs.com/ztz13125073098/p/3601046.html

Guess you like

Origin blog.csdn.net/weixin_34270606/article/details/94491029