iOS Question NSFileCreationDate shows GMT

Discussion in 'iOS Questions' started by tufanv, May 15, 2018.

  1. tufanv

    tufanv Expert Licensed 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 .
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please post the relevant code.

    Why aren't you using File.LastModified?
     
  3. tufanv

    tufanv Expert Licensed User

    it is also gmt as I can see , this is the output:

    Code:
    (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 :
    Code:
    LogFile.GetAttributes(File.DirDocuments,File.ListFiles(File.DirDocuments).Get(i)))
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    This is very inefficient code, assuming that you are calling it multiple times.

    Correct code:
    Code:
    For Each f As String In File.ListFiles(File.DirDocuments)
       
    Log($"$DateTime{File.LastModified(File.DirDocuments, f)}"$)
    Next
     
    tufanv likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice