new Date () and setDate () parameters

A Date new () and setDate () parameters

I believe the Internet has been a lot of articles about the date, here's just a matter of my own work and then met again be summarized;

new Date()

   new Date () form a total of six, with one of the five parameters without parameters;

  1. new Date (); natural Needless to say, the default is the current date acquired.
  2. new Date ( "month1 dd, yyyy hh: mm: ss"); Note: the parameter is a character form
  3. new Date ( "month1 dd, yyyy"); Note: the parameter is a character form
  4. new Date (yyyy, month2, dd, hh, mm, ss); Note: The parameter is not character
  5. new Date (yyyy, month2, dd); Note: The parameter is not character
  6. new Date(ms); 

  Parameter Description:

  month1: English, the name of the month; from January to December;

  dd: date, and 1-31

  yyyy: Represents the year represented four

  hh: mm: ss: represents time, while (0-23) - min (0-59) - s (0-59)

  month2: is a Number of the month; from 0-11; ie January to December

  ms: number of milliseconds from between 1 January 1970 the difference

 

Special note: Some of the characters in the form of some not

 

setDate()

  We often work with setDate () the date of realization of addition and subtraction; setDate () receives an integer, if this integer greater than the current time on the day of the month subject line is automatically go-ahead, the remainder is the date of the next month

  var d=new Date(2019,1,21);

  d.setDate(d.getDate()+15);

  Special note: setDate () received an integer

 

 

 

 

 

 

 
Category:  JS

A Date new () and setDate () parameters

I believe the Internet has been a lot of articles about the date, here's just a matter of my own work and then met again be summarized;

new Date()

   new Date () form a total of six, with one of the five parameters without parameters;

  1. new Date (); natural Needless to say, the default is the current date acquired.
  2. new Date ( "month1 dd, yyyy hh: mm: ss"); Note: the parameter is a character form
  3. new Date ( "month1 dd, yyyy"); Note: the parameter is a character form
  4. new Date (yyyy, month2, dd, hh, mm, ss); Note: The parameter is not character
  5. new Date (yyyy, month2, dd); Note: The parameter is not character
  6. new Date(ms); 

  Parameter Description:

  month1: English, the name of the month; from January to December;

  dd: date, and 1-31

  yyyy: Represents the year represented four

  hh: mm: ss: represents time, while (0-23) - min (0-59) - s (0-59)

  month2: is a Number of the month; from 0-11; ie January to December

  ms: number of milliseconds from between 1 January 1970 the difference

 

Special note: Some of the characters in the form of some not

 

setDate()

  We often work with setDate () the date of realization of addition and subtraction; setDate () receives an integer, if this integer greater than the current time on the day of the month subject line is automatically go-ahead, the remainder is the date of the next month

  var d=new Date(2019,1,21);

  d.setDate(d.getDate()+15);

  Special note: setDate () received an integer

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/chenqingbin/p/11803513.html