JavaScript compares days between two dates

Source: Internet
Author: User
The code is as follows Copy Code

$ (function () {
var starttime = transdate ("2014-09-30 15:53:00");
var endtime = transdate ("2014-10-03 15:53:00");

var now = "'" +new Date (). GetTime () + "'";
var nowtime = now.substr (1,10);

if (Nowtime > Endtime) {
$ ('. Meeting_time '). HTML (' show closed ');
}else if (Nowtime < StartTime) {
var day = get_date_different (nowtime,starttime);
$ ('. Meeting_time '). HTML (' from the beginning of the show and ' +day+ ' Day ');
}else{
$ ('. Meeting_time '). HTML (' Show in progress ');
}
});
function Get_date_different (date_1,date_2) {
var days= date_2-date_1;
var time = parseint (days/(60 * 60 * 24));
return time;
}
function TransDate (endtime) {
var date=new date ();
Date.setfullyear (endtime.substring (0,4));
Date.setmonth (endtime.substring (5,7)-1);
Date.setdate (endtime.substring (8,10));
Date.sethours (endtime.substring (11,13));
Date.setminutes (endtime.substring (14,16));
Date.setseconds (endtime.substring (17,19));
Return Date.parse (Date)/1000;
}

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.