/** * milliseconds conversion friendly display format * output format: 21 hours 28 minutes 15 seconds * @param {[type]} time [description] * @return {[type]} [description]*/functionTimetodate (time) {//gets the current time stamp varCurrentTime = parseint (NewDate (). GetTime ()/1000);varDifftime = currenttime-Time ; varSecond = 0; varminute = 0; varHour = 0; if(NULL! = Difftime && ""! =difftime) { if(Difftime > && difftime < 60 * 60) {Difftime= parseint (difftime/60.0) + "minutes" + parseint ((parsefloat (difftime/60.0)-parseint (difftime/60.0)) * 60) + "seconds"; } Else if(Difftime >= * && Difftime < 60 * 60 * 24) {Difftime= parseint (difftime/3600.0) + "Hour" + parseint (parsefloat (difftime/3600.0)-parseint (Difftime/3600.0)) * 60) + "minutes" +parseint ((parsefloat (parsefloat (difftime/3600.0)-parseint (difftime/3600.0)) * 60)-parseint ((parsefloat (Difftime/3600.0)-parseint (difftime/3600.0)) * 60)) * 60) + "seconds"; } Else { //more than 1 days varDate =NewDate (parseint (time) * 1000); Difftime= Date.getfullyear () + "/" + (Date.getmonth () +1) + "/" +date.getdate (); //difftime = parseint (difftime) + "second"; } } returnDifftime;}
/** * milliseconds conversion friendly display format * output format: 21 hours ago * @param {[type]} time [description] * @return {[type]} [description]*/functionDatestr (date) {//Get JS timestamp varTime=NewDate (). GetTime (); //remove three bits after JS timestamp, consistent with PHP timestampTime=parseint ((time-date*1000)/1000);//Store Conversion Values vars; if(TIME<60*10) {//within 10 minutes returnJust; }Else if((time<60*60) && (time>=60*10)){ //more than 10 minutes less than 1 hourss = Math.floor (TIME/60);returnS+ "Minutes Ago"; }Else if((time<60*60*24) && (time>=60*60)){ //more than 1 hours less than 24 hourss = Math.floor (time/60/60); returnS+ "Hours Ago"; }Else if((time<60*60*24*3) && (time>=60*60*24)){ //less than 3 days in excess of 1 dayss = Math.floor (TIME/60/60/24);returnS+ "Days Ago"; }Else{ //more than 3 days varDate=NewDate (parseint (date) * 1000); returnDate.getfullyear () + "/" + (Date.getmonth () +1) + "/" +date.getdate (); }}
JS Display friendly time format "Just, a few seconds ago, hours, days ago (within 3 days) time format"