A Simple Example of JS Getting Random Numbers and Time Transformations
- 2021-07-02 23:09:04
- OfStack
Math. floor (Math. random () * 10); //Generate random numbers within 10
new Date (); //Get the current time (string type)
new Date (). getTime (); //Get the current number of milliseconds
new Date (1356334057000); //Create time in milliseconds
new Date (). getMonth () +1; //Get the month, starting at 0, so add 1
new Date (). getFullYear (); //Get Year
new Date (). getDay () +1; //Get the current week X, starting at 0
new Date (). getDate ()); //Acquisition Date
new Date (). getHours ()//Get hours
new Date (). getMinutes ()//Get minutes
new Date (). getSeconds ()//Get seconds