You can use unixtime expression. While the game is running, save unixtime in local storage. (say, every few seconds or at the end of each level)
When the game starts, try to read it from local storage.
int((unittime-saved_unixtime)/60000)=number of minutes spent offline