Adjusting Date and time modified of files in File Manager based on a specified timezone

Hi,

Is there a way where I can update the date and time modified of files in the File Manager based on a timezone that will be specified in the code?

We have this requirement where we can change the timezone setting of the website and this affects all dates and times in the website which includes the date modified field of the files in File Manager.

Thanks!


1 Reply

SM Shalini Maragathavel Syncfusion Team July 16, 2021 01:04 PM UTC

Hi Denzel, 

Greetings from Syncfusion support.
                                                                                                                                         
We checked your query and would like to let you know that, by default the date in the detail view column of File Manager will be displayed based on the date returned from the server. You can return the required customized date from the server and set the customized date in the detail view column as demonstrated in the below code snippet, 
Homecontroller.cs

public object getFiles(FileManagerDirectoryContent args)
 
    { 
      FileResponse readResponse = new FileResponse(); 
      try 
      { 
        var value = this.operation.GetFiles(args.Path, args.ShowHiddenItems); 
        DirectoryContent cwd = new DirectoryContent(); 
        readResponse.CWD = JsonConvert.DeserializeObject<DirectoryContent>(JsonConvert.SerializeObject(value.CWD)); 
        readResponse.Files = JsonConvert.DeserializeObject<IEnumerable<DirectoryContent>>(JsonConvert.SerializeObject(value.Files)); 
        //Add the additional parameter for each files in filemanager component. 
        foreach (DirectoryContent file in readResponse.Files) 
        { 
          // Converting Date and Time. 
          file.DateModified = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")); 
        } 
        readResponse.Details = value.Details; 
        readResponse.Error = value.Error; 
        return readResponse; 
      } 
      catch 
      { 
        ErrorDetails er = new ErrorDetails(); 
      } 
      return this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems)); 
    } 

[Route("FileOperations")] 
    public object FileOperations([FromBody] FileManagerDirectoryContent args) 
    { 
      switch (args.Action) 
      { 
        case "read": 
          // reads the file(s) or folder(s) from the given path.
         return this.getFiles(args); 
}

-------------------------------------------------------------------------
index.razor 
   <SfFileManager TValue="FileManagerDirectoryContent" View="ViewType.Details"> 
       <FileManagerDetailsViewSettings> 
            <FileManagerColumns> 
                <FileManagerColumn Field="DateModified" HeaderText="Date Modified"> 
                </FileManagerColumn>  
            </FileManagerColumns> 
        </FileManagerDetailsViewSettings> 
   </SfFileManager> 

In the above sample, we have converted the date time as Eastern Standard Time format for reference. Likewise, you can customize the date time according to your required format

Please find the below sample for your reference. 

Please get back to us if you need further assistance.  

Regards,  
Shalini M. 


Loader.
Up arrow icon