How long ago Jquery

Source: Internet
Author: User

Time difference

  <script>        $ (function () {             var s Tart = "2015-10-15 10:00:00";            var end = "2015-10-15 10:00:05";    &nbsp ;       var result = Getdatediff (start, end);       });                //Time format: 2015-10-15 10:21:00        function Getdatediff (StartTime, Endtim e) {           //Convert XXXX-XX-XX time format to XXXX/XX/XX format          &NBSP ;   StartTime = Starttime.replace (/-/g, "/");            EndTime = Endtime.replace (/-/g, "/");           //Convert the computed interval class character to lowercase              var stime = new Date (startTime); Start time              var etime = new Date (endTime); End time             var result= "";             var SECONDC = 1000;            var Minutec = Secondc * 60;            var HOURC = Minutec * 60;            var dayc = Hourc * 24;            var monthc = dayc * 30 ;            var yearc = monthc * 12;             VAR dif Ftime = parseint (Etime.gettime ()-Stime.gettime ());                   & nbsp   var Yearr = Difftime/parseint (YEARC);            var monthr = Difftime/parseint (M ONTHC);            var DayR = Difftime/parseint (DAYC);          & nbsp var Hourr = difftime/parseint (HOURC);            var minuter = Difftime/parseint (Minutec );  &NBSp         var secondr = Difftime/parseint (SECONDC);             &NB Sp         if (Yearr >= 1) {                result = parseint ( Yearr) + "years ago";           } else if (monthr >= 1) {          &NB Sp     result = parseint (MONTHR) + "month ago";           } else if (dayr>=1) {  &N Bsp             result = parseint (DayR) + "days ago";           } else if (Hourr >= 1) {                result = parseint (Hourr) + "hour Ago";           } else if (minuter >= 1) {                result = parseint (Minuter) + "minutes ago";           }else {            &NBS P &nbsP result = "just";           }            alert (result);  &NB Sp    }      </script>

How long ago Jquery

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.