您可以签出以下代码:
var today = new Date();var Christmas = new Date("2012-12-25");var diffMs = (Christmas - today); // milliseconds between now & Christmasvar diffDays = Math.floor(diffMs / 86400000); // daysvar diffHrs = Math.floor((diffMs % 86400000) / 3600000); // hoursvar diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutesalert(diffDays + " days, " + diffHrs + " hours, " + diffMins + " minutes until Christmas 2009 =)");
或
var diffMins = Math.floor((...舍弃秒,如果您不想舍入分钟。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)