Skip to content

Wrong date calculated with lastModified() #1857

Open
@lucasRolff

Description

@lucasRolff

Bug Report

Q A
Flysystem Version 3.29.1
Adapter Name ftp
Adapter version 3.29.0

Summary

If you have a file which is modified in e.g. September 30, 2024, lastModified() within the FTP adapter, will show September 30, 2025.
This is due to how Linux seemingly shows dates, if a file modified is within 6 months, it will not list the year.

If you do a stat on the file, it will obviously show the correct modified time:

[root@nlsh04 example.com]# stat .htaccess
  File: .htaccess
  Size: 525       	Blocks: 8          IO Block: 4096   regular file
Device: 97fh/2431d	Inode: 2150978085  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1127/example)   Gid: ( 1130/example)
Access: 2025-02-19 02:01:31.360548141 +0000
Modify: 2024-09-30 12:58:00.331455453 +0000
Change: 2024-09-30 12:58:00.331455453 +0000
 Birth: 2024-09-30 12:58:00.331455453 +0000

However, through normal ls -al, you'll simply see Sep 30:

[root@nlsh04 example.com]# ls -al .htaccess
-rw-r--r-- 1 example example 525 Sep 30 12:58 .htaccess

In FTP, such as lftp, you'll see it similarly:

lftp [email protected]:/domains/example.com> ls -l .htaccess
-rw-r--r--    1 1127       example          525 Sep 30 12:58 .htaccess

If you dump the FileAttributes for a given file:

League\Flysystem\FileAttributes {#2520 ▼ // app/Livewire/Panel/Tools/FileManager.php:121
  -type: "file"
  -path: "domains/example.com/.htaccess"
  -fileSize: 525
  -visibility: "public"
  -lastModified: 1759237080
  -mimeType: null
  -extraMetadata: []
}

As we can see here, the lastModified according to flysystem, also converts to Tuesday, 30 September 2025 12:58:00.

It would be nice if it would list the actual modified time.

How to reproduce

  1. Create a file such as text.txt that has a modified date in the past 6 months, ideally something within 2024 on a Linux environment (I use RHEL9 flavor (AlmaLinux in this case).
  2. Do a stat on the file from the filesystem, you should see modified time being what you set, with 2024.
  3. Do a ls/stat within FTP, you should likely see the date but as in 2025, despite this date haven't yet passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions