Android Question how can i compare modify time of 2 files ?

nima8686

New Member
hello , i want to compare modify time of 2 file .
i got the time of modify by long type but it dosnt work i want to check exact info to compare like day ,hour ... seconds .. how can i do that ?
 

William Lancee

Well-Known Member
Licensed User
Longtime User
B4X:
    Dim d As Long = File.LastModified(File.DirApp, "page1.txt")
    Log(DateTime.GetYear(d) & TAB & DateTime.GetMonth(d) & TAB & DateTime.GetDayOfMonth(d))
    Log(DateTime.GetHour(d) & TAB & DateTime.GetMinute(d) & TAB & DateTime.GetSecond(d))
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
The File.LastModified property gives the time that the file was last modified (or created, if unmodified) to the millisecond, so no need to convert it to minutes and seconds - just compare the values for the two files.

[By the way, if you need to compare a file modified time with the time of a file uploaded to a net location then you need to correct to UTC.]
 
Last edited:
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
If you want to know seconds between dates then do this.
If you want this difference in number of hours, days, etc. use the DateUtils Library instead.

B4X:
    Dim d1 As Long = File.LastModified(File.DirApp, "page1.txt")
    Dim d2 As Long = File.LastModified(File.DirApp, "trackingRecords.txt")
    Log((d2 - d1) / 1000)        '# seconds difference, if negative d1 is later than d2
 
Upvote 0
Top