iOS Question NSFileCreationDate shows GMT

tufanv

Expert
Licensed User
Longtime User
Hello,

I use file.getattributes to get the details of a file in file.dirdocuments. NSFileCreationDate shows GMT time for the creation while my local time is GMT +3 , is this normal and I need to add hours to show it in my local timezone ? ( but my timezone changes 1 time every year so is there a better way ? )

Thanks .
 

tufanv

Expert
Licensed User
Longtime User
it is also gmt as I can see , this is the output:

B4X:
(read only map) {
    NSFileCreationDate = "2018-05-15 15:47:39 +0000";
    NSFileExtensionHidden = 0;
    NSFileGroupOwnerAccountID = 501;
    NSFileGroupOwnerAccountName = mobile;
    NSFileModificationDate = "2018-05-15 15:47:42 +0000";
    NSFileOwnerAccountID = 501;
    NSFileOwnerAccountName = mobile;
    NSFilePosixPermissions = 420;
    NSFileProtectionKey = NSFileProtectionCompleteUntilFirstUserAuthentication;
    NSFileReferenceCount = 1;
    NSFileSize = 49111;
    NSFileSystemFileNumber = 8273908;
    NSFileSystemNumber = 16777221;
    NSFileType = NSFileTypeRegular;
}

this is the code I use :
B4X:
Log( File.GetAttributes(File.DirDocuments,File.ListFiles(File.DirDocuments).Get(i)))
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Log( File.GetAttributes(File.DirDocuments,File.ListFiles(File.DirDocuments).Get(i)))
This is very inefficient code, assuming that you are calling it multiple times.

Correct code:
B4X:
For Each f As String In File.ListFiles(File.DirDocuments)
   Log($"$DateTime{File.LastModified(File.DirDocuments, f)}"$)
Next
 
Upvote 0
Top