// Friendly time return function (for example, 10 minutes ago) time_stamp is UNIX second function friendly_time (time_stamp) {var now_d = new date (); var now_time = now_d.gettime () /1000; // obtain the current time in seconds var f_d = new date (); f_d.settime (time_stamp * 1000); var f_time = f_d.tolocaledatestring (); var Ct = now_time-time_stamp; vaR day = 0; If (CT <0) {f_time = "[reservation]" + f_d.tolocalestring ();} else if (CT <60) {f_time = math. floor (CT) + 'second before ';} else if (CT <3600) {f_time = math. floor (CT/60) + 'minute ago ';} else if (CT <86400) // One day {f_time = math. floor (CT/3600) + 'hour before ';} else if (CT <604800) // 7 days {day = math. floor (CT/86400); If (day <2) f_time = 'Yesterday '; else f_time = day + 'day before';} else {day = math. floor (CT/86400); f_time = day + 'day';} return f_time;} function getd (time1) {var da = new date (); SDA = new date (time1); var time2 = da. gettime (); var time = 0; If (time1> time2) {time = time1-time2; SDA = da;} else {time = time2-time1 ;} if (time <1000) Return "just"; time = parseint (Time/1000); If (Time> 86400) {var day = parseint (Time/(24*60*60); If (Day = 1) {return "yesterday (" + SDA. gethours () + ":" + SDA. getminutes () + ")" ;}else if (day <30) {return day + "Days Ago" ;}else if (day <360) {var moth = parseint (day/30); Return moth + "Months Ago";} else {var year = parseint (day/360 ); return year + "years ago" ;};}else if (Time> 3600) {var hour = parseint (Time/(60*60 )); return hour + "Hours Ago";} else if (Time> 60) {var hour = parseint (Time/60); Return hour + "Minutes Ago ";} else {return time + "seconds ago ";}}
Sometimes the win7 system automatically displays the time in the format of a week.
VaR Rg = new Regexp ("[October 6, 1234]", "G ");
VaR q = obj_datetine.replace (RG, ""). Replace ("-", "/"); // obj_datetine is the time parameter to be processed
var d = new Date(Date.parse(q));
return friendly_time(d.getTime() / 1000);