Skip to content

Finder Component. Date method not working properly #9303

@peter-gribanov

Description

@peter-gribanov

I want to delete files older than one hour

$finder = new Finder();
$finder->in($dir)->date('< 1 hour ago')->ignoreUnreadableDirs();
foreach ($finder as $file) {
    var_dump($file->getMTime() < strtotime('1 hour ago'));
}

The result obtained

bool(true)
bool(true)
bool(false)

Which gives false, files really changed less than an hour ago.

$ date +'%F %T'
2013-10-16 11:23:03
$ ls -Gn --full-time
drwxrwxr-x 2 1000 4096 2013-08-05 15:45:31.295648000 +0400 dummy
drwxrwxr-x 2 1000 4096 2013-10-15 13:19:24.781790000 +0400 example
drwxrwxr-x 2 1000 4096 2013-10-16 11:02:10.152208721 +0400 test
-rw-rw-r-- 1 1000    0 2013-10-16 11:02:20.076209132 +0400 test_file1

What am I doing wrong?!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions