You will need to periodically store the timer value into a persistent variable - how you do this depends on how precise you need to be and how big you expect the value to reach, all depends on your specific requirements. You need to have a good understanding of the limitations of the underlying data types (storage AND arithmetic operations).
See Totalizing: 101 - On-Time totalizer pump example and read all the comments for the issues you need to consider.
If you have questions on any of that, or need a specific recommendation, please ask.