Countdown System ..How?

Dear, I want to make countdown systems like 24 hours or 1-hour timer. How can I make this? Make sure when a user exits its work on the background or when user clear data and when the user is offline it works.