javascript比較兩個日期之間相隔天數

來源:互聯網
上載者:User

javascript比較兩個日期之間相隔天數


$(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('展會已結束');
}else if(nowtime < starttime){
var day = get_date_different(nowtime,starttime);
$('.meeting_time').html('距展會開始還有'+day+'天');
}else{
$('.meeting_time').html('展會進行中');
}
});
function get_(www.111cn.net)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;
}from:http://www.111cn.net/wy/js-ajax/66437.htm

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.