当幸福来敲门

我就会牢牢抓住!
随笔 - 50, 文章 - 3, 评论 - 8, 引用 - 0
数据加载中……

JS 两个时间之间相关问题


    var OneMonth = start.substring(5,start.lastIndexOf ('-'));  
    var OneDay = start.substring(start.length,start.lastIndexOf ('-')+1);  
    var OneYear = start.substring(0,start.indexOf ('-'));  
  
    var TwoMonth = end.substring(5,end.lastIndexOf ('-'));  
    var TwoDay = end.substring(end.length,end.lastIndexOf ('-')+1);  
    var TwoYear = end.substring(0,end.indexOf ('-'));  
  
    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);   
     alert(cha);


var date1=new Date("2008/7/29");
var date2=new Date();
var nDiff=date2-date1;
var nHour,nMini,nSecond;

nHour=parseInt(nDiff/3600000);
nMini=parseInt((nDiff%3600000)/60000);
alert("今天距离昨天零点:\n"
  +nHour+":小时\n"
  +nMini+":分钟");

http://blog.csdn.net/xuStanly/article/details/2186411

posted on 2011-11-09 17:32 wyx 阅读(154) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: