Skip to content

Instantly share code, notes, and snippets.

@kiinlam
Last active February 10, 2017 08:27
Show Gist options
  • Save kiinlam/1191a243caf58a528b24470aa5858d91 to your computer and use it in GitHub Desktop.
Save kiinlam/1191a243caf58a528b24470aa5858d91 to your computer and use it in GitHub Desktop.
倒计时 Remaining time
function remainingTime (rt) {
var hour = (rt | 0)/(3600*1000) | 0,
minute = ((rt | 0)%(3600*1000))/(60*1000) | 0,
second = ((rt | 0)%(3600*1000)%(60*1000))/1000 | 0;
if (rt <= 0) {
return;
} else {
setTimeout(function(){
remainingTime(rt - 1000);
}, 1000);
return {
hour: hour,
minute: minute,
second: second
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment