Js converts timestamp to date format
// Simple code var date = new Date (timestamp); // get a time object Note: if it is a uinx timestamp, remember to multiply it by 1000. For example, the timestamp obtained by the php function time () must be multiplied by 1000/* ---------- the following is the method for obtaining the time and date. You can just splice the time formats ---------- */date. getFullYear (); // obtain the complete year (4 bits, 1970) date. getMonth (); // obtain the month (0-11, 0 represents January, remember to add 1) date. getDate (); // get the date (1-31. getTime (); // obtain the time (number starting from 1970.1.1) date. getHours (); // obtain the hour (0-23) date. getMinutes (); // get the number of minutes (0-59) date. getSeconds (); // obtain the number of seconds (0-59) // more useful methods can be found here-> // example, for example, the following format is required: yyyy-MM-dd hh: mm: ssvar date = new Date (139825054949) 0); Y = date. getFullYear () + '-'; M = (date. getMonth () + 1 <10? '0' + (date. getMonth () + 1): date. getMonth () + 1) + '-'; D = date. getDate () + ''; h = date. getHours () + ':'; m = date. getMinutes () + ':'; s = date. getSeconds (); console. log (Y + M + D + h + m + s); // Ah Ma dish // output result: 18:55:49 convert the date format to the timestamp: // It is also very simple date = new Date ('2017-04-23 18: 55: 49: 2014 '); // input a time format, if it is not passed in, the current time is obtained. // You can obtain time1 = date in three ways. getTime () time2 = date. valueOf () time3 = Date. parse (date) // the difference between the first and second types: accurate to the third type: accurate to seconds, 0 will be used to replace // The output result of the above Code (the difference can be seen at a Glance): // 1398250549123 // 1398250549123 // 1398250549000