<script type="text/
javascript">
function test(str){
var dateStr = str;
var date = new Date(dateStr);
var now = new Date();
var mis = now.getTime() - date.getTime();
var daysCount = 24 * 60 * 60 * 1000;
var days = parseInt(mis/daysCount);
//m(days);
var mis = mis % daysCount;
var hoursCount = daysCount /24;
var hours = parseInt(mis/hoursCount);
var mis = mis % hoursCount ;
var minsCount = hoursCount / 60;
var mins = parseInt(mis/minsCount);
var mis = mis % minsCount;
var sesCount = minsCount /60;
var ses = parseInt(mis/sesCount);
var msg = days>0 ? '已经有' : '还有';
days = days>0 ?days : days /-1;
days=days+1;
hours = hours>0 ?hours : hours /-1;
mins = mins>0 ?mins : mins /-1;
ses = ses>0 ?ses : ses /-1;
var shijian = "与你已认识"+ msg + days + '天' + hours + '小时' + mins + '分' + ses + '秒';
alert(shijian)
}
test("2011/11/20 8:30:00");//----距离时间---
</script>