1. Ask for the current time.
var curdate = new Date ();
2. Ask for the day before the current time
var predate = new Date (Curdate.gettime () -24*60*60*1000);
3. Time format conversion.
You can find the date format above. Mon June 17:21:50 gmt+0800 (China Standard Time)
We are free to convert the format, using the date of the function above as the parameter.
function FormatDateTime (date) { // Converts the time to the desired format var y = date.getfullyear (); = Date.getmonth () + 1; = M < 10? ' 0 ' + m:m; = date.getdate (); = d < 10? (' 0 ' + D): D; = date.gethours (); = h < 10? (' 0 ' + D): h; = date.getminutes (); = Mi < 10? (' 0 ' + mi): mi; Console.log (h); Console.log (d); return y + ' year ' + M + ' month ' + d+ ' Day ' + H + ': ' + mi;}
4. Timestamp 10-bit and 13-bit differences
The accuracy is different, 10 bits to 13 bits multiplied by 1000, 13 bits into 10 bits divided by 1000.java is 13 bits, PHP is 10 bits.
Some questions about JavaScript time