Math Math and Date date in javascript

     Math Math

      Math.PI; pi constant

      Math.E; the natural logarithm constant

      Math.abs (-2); absolute value

      Math.pow (2,3); power, equivalent to 2 ** exponentiation 3

      Math.sqrt (9); square root

      Math.pow (9,1 / 3; open square root of any

      Math.sin (30 * Math.PI / 180); sine

      Math.max (1,8,2); maximum

      Math.min (5,2,7); Min

 

        Math.round (3,5); rounding

        Math.floor (3.6); rounding down

        Math.ceil (3.4); rounding up

 

         Math.random (); random number, returns [0,1] is a decimal floating point someone

         Date Date

         1 . Current time

             var now=new Date();

          2 . Object generation date known time

              var yesterday=new Date();

         3 . Time format cut

                    Save target time at 0:00:00 on January 1, 1970 the number of seconds is ten milliseconds after three seconds.

                    Disadvantages: unnatural, limited performance time.

                    Advantages: Date of addition and subtraction, more convenient morning and evening.

               now.getTime();

                Date.parse(now);

          4 Take the year, month, day, hour, minute, second

                now.getFullYear();

                 now.getMonth();

                 now.getDay();

                 now.getHours();

                 now.getMinutes();

                 now.getSeconds();

                 now.getMilliseconds();

                         GMT, excluding time zone. We usually use are generally local time local time zone count.

           5 . Date Format

                          js does not provide ready-date formatting functions, it needs its own wrapper function.

                   now.format('YYYY-MM-DD  hh:mm:ss')

      

Guess you like

Origin www.cnblogs.com/english19990-inng/p/11564448.html