JS JQ plugin Display Chinese timestamp just n minutes ago N hours ago this morning afternoon

Source: Internet
Author: User

$.fn.extend ({/** * The timestamp is displayed as "Not long ago, just, n minutes before, n hours ago, n days ago, n weeks ago, n months ago, n years n months n days" of processing * *.  * * $ (' 1517451000000 '). Commontimestamp ();  February 01, 2018 * * $ (new Date (' 2018-02-01 15:10:00 '). GetTime ()). Commontimestamp (); 1 minutes ago*/        "Commontimestamp": Function () {//13-bit full complement            varArrtimestamp = ( This. selector | | $( This)[0] +"'). Split ("'), Zero= function (value) {//0 Method of numerical complement                    if(Value <Ten) {                        return '0'+value; }                    returnvalue; }, Arrtime={minute:60000,//*,Hour3600000,//* * ,Day86400000,//* * * ,Week604800000,//* 7,Halfamonth:1296000000,//* * * ,Month2592000000,//* * * ,NowNewDate (). GetTime ()};  for(varStart =0; Start < -; start++) {                if(!Arrtimestamp[start]) {Arrtimestamp[start]='0'; }} Arrtimestamp= Arrtimestamp.join ("') *1; Arrtime.diffvalue=NewDate (). GetTime ()-Arrtimestamp; //If the local time is less than the variable time            if(Arrtime.diffvalue <0) {                return 'Not long ago'; }            //magnitude of variance time calculation            varArrtimediff ={MonthC:arrTime.diffValue/Arrtime.month, WeekC:arrTime.diffValue/Arrtime.week, DayC:arrTime.diffValue/Arrtime.day, HourC:arrTime.diffValue/Arrtime.hour, MinC:arrTime.diffValue/Arrtime.minute,}; //Use            if(Arrtimediff.monthc > A) {                //more than 1 years, direct display month Day                return(function () {varDate =NewDate (Arrtimestamp); returnDate.getfullyear () +'years'+ zero (date.getmonth () +1) +'Month'+ zero (date.getdate ()) +'Day';            })(); } Else if(ARRTIMEDIFF.MONTHC >=1) {                returnparseint (ARRTIMEDIFF.MONTHC) +"months ago"; } Else if(ARRTIMEDIFF.WEEKC >=1) {                returnparseint (ARRTIMEDIFF.WEEKC) +"weeks ago"; } Else if(Arrtimediff.dayc >=1) {                returnparseint (ARRTIMEDIFF.DAYC) +"days ago"; } Else if(Arrtimediff.hourc >=1) {                returnparseint (ARRTIMEDIFF.HOURC) +"hours ago"; } Else if(Arrtimediff.minc >=1) {                returnparseint (Arrtimediff.minc) +"minutes ago"; }            return 'just'; },        /** * The timestamp is displayed as "Today 10:10, today 15:10, yesterday 10:10, yesterday 15:10, 10:10, 15:10" Treatment * *.  * * $ (' 1517451000000 '). Specifictimestamp ();  This Morning 10:10 * * $ (new Date (' 2018-02-01 15:10:00 '). GetTime ()). Specifictimestamp (); 15:10 this afternoon .*/        "Specifictimestamp": Function () {varArrtimestamp = This. selector | | $( This)[0] -0, Partime=NewDate (arrtimestamp), Diffday= parseint ((NewDate (). GetTime ()-Arrtimestamp)/( +* -* -* -)); //Use            return((Diffday >=1&& Diffday <=2) ?"Yesterday": (Diffday>=0&& Diffday <=1) ?"Today":"") +( (partime.gethours ()/ A>1?"Afternoon":"Morning") +partime.gethours ()+":"+partime.getminutes ()); }    });

JS JQ plugin Display Chinese timestamp just n minutes ago N hours ago this morning afternoon

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.