JS_Date date-time object

1. Get the current time

<Script>
     // get the current time 
    var now = new new a Date () 
    the console.log (now)
 </ Script>

result:

 2. Custom Time

<Script>
     // string customize time 
    var xmas Dominant = new new a Date ( 'December 25,1998 13:30:30' ) 
    the console.log (xmas Dominant) 
    // parameter customize time, the month (0-11) 
    var = xmas Dominant new new a Date (1995,11,25 ) 
    the console.log (xmas Dominant) 
    var xmas Dominant = new new a Date (1995,11,25,14,30,0 ) 
    the console.log (xmas Dominant)
 </ Script>

result:

 

 3. The common method

<Script>
     var now = new new a Date () 
    console.log (now) 
    // get the current time in the first few days of the month 
    console.log (now.getDate ())
     // get the current time of the current month 
    console.log (now .getMonth ())
     // get the current time in the current year 
    console.log (now.getFullYear ())
     // get the week (0-6) 0 6 for the weekend is Saturday 1 Monday 
    console.log (now.getDay ())
     // get the current time in hours 
    console.log (now.getHours ())
     // get the current time minutes 
    console.log (now.getMinutes ())
     // get the number of seconds the current time 
    console.log (now .getSeconds ())
 </ Script>

result:

 

 

Guess you like

Origin www.cnblogs.com/wangdianchao/p/12670809.html