@ShinyBug
I wanted to do something similar, but I would recommend using UNIX time/date as GetUnixFromDate() gives access to year, month, days, hours, minutes, seconds. Calculating the difference in time between the two is easier. Also I would not use GoSub/Return.
I wrote an example in the AppGameKit help files that you may find useful.
http://www.appgamekit.com/documentation/Reference/File/GetFileExists.htm
// Project: forever time
// Created: 2015-01-17
Setvirtualresolution(640,480)
ResetTimer()
// Check if file exists, if it does then read the stored UNIX time value,
// if not, create it and store current UNIX time/date in the file.
If GetFileExists(\"__timer__\")
id=OpenToRead(\"__timer__\")
oldtime=ReadInteger(id)
CloseFile(Id)
Else
date$=GetCurrentDate()
time$=GetCurrentTime()
unix=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),Val(Left(time$,2)),Val(Mid(time$,4,2)),Val(Right(time$,2)))
id=OpenToWrite(\"__timer__\")
WriteInteger(id,unix)
CloseFile(id)
oldtime=unix
EndIf
do
date$=GetCurrentDate()
time$=GetCurrentTime()
nowtime=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),Val(Left(time$,2)),Val(Mid(time$,4,2)),Val(Right(time$,2)))
test=nowtime-oldtime
sec=Mod(test,60)
test=Floor(test/60)
min=Mod(test,60)
test=Floor(test/60)
hour=Mod(test,60)
Print(Str(hour)+\" Hour \"+Str(min)+\" Min \"+Str(sec)+\" Sec\")
Print(\"Since this app was first started\")
Sync()
If Timer()>15 Then Exit
Loop
//To delete the timer file, uncomment the following line
//DeleteFile(\"__timer__\")
End