Background data creationtime in the background is the date type
Milliseconds into the May-2 April day format.
- Get the month day get date Otime
- function Getmoth (str) {
- var odate = new Date (str),
- Omonth = Odate.getmonth () +1,
- Oday = Odate.getdate (),
- Otime = Getzf (omonth) +'-' + GETZF (oday);//Last splicing time
- return otime;
- };
- Console.log (Getmoth (1465959000));//How to use
Milliseconds converted to Month Day + time and minute format 1970-01-18 07:12:39
0 Operations: For example, 2012-2-2 will become 2012-02-02
Method of Use: Getmydate (data[i].creationtime);
- Obtained date Otime
- function Getmydate (str) {
- var odate = new Date (str),
- Oyear = Odate.getfullyear (),
- Omonth = Odate.getmonth () +1,
- Oday = Odate.getdate (),
- Ohour = Odate.gethours (),
- Omin = Odate.getminutes (),
- OSen = Odate.getseconds (),
- Otime = oyear +'-' + GETZF (omonth) + '-' + GETZF (oday) + ' + GETZF (ohour) +': ' + GETZF (omin) +': ' +getzf (OS EN);//Last splicing time
- return otime;
- };
- Complement 0 Operations
- function Getzf (num) {
- if (parseint (num) < ) {
- num = ' 0 ' +num;
- }
- return num;
- }
Milliseconds converted to month and day time and minute format
- /*
- JS by the number of milliseconds to get the date
- Use: (New Date (Data[i].creationtime)). Format ("Yyyy-mm-dd hh:mm:ss. S ")
- */
- Date.prototype.Format = function (FMT) {//author:meizz
- var o = {
- "m+": this.getmonth () + 1,//month
- "d+": this.getdate (),//day
- "H +": this.gethours (),//hour
- "m+": this.getminutes (),//min
- "s+": This.getseconds (),//Sec
- "q+": Math.floor ((This.getmonth () + 3)/ 3),//quarterly
- "S": this.getmilliseconds ()//MS
- };
- if (/(y+)/.test (FMT)) FMT = Fmt.replace (regexp.$1, (this.getfullyear () + ""). substr (4-regexp.$1. length));
- For (var k in O)
- if (New RegExp ("(" + K + ")"). Test (FMT)) FMT = Fmt.replace (regexp.$1, (regexp.$1.length = = 1)? (O[k]): (("xx" + o[k]). substr (("" + O[k]).));
- return FMT;
- };
Use JS to complete the date format task of millisecond format data