Version: v0.8.1 - Beta.  We welcome contributors & feedback.

File.getDate

$path.getDate() -> Map<Date>

Description

Get the date info of a file or directory as a Map of Date objects.

Date Key Description
modified Date last written to.
accessed Date last opened for reading or writing.
created? (see below)
$fileDate = file'files:/some/data.txt'.getDate()

// {
//    modified: 《 Date 2024-07-26 16:45:12 +0000 》
//    accessed: 《 Date 2024-08-30 20:33:51 +0000 》
//    created?: 《 Date 2024-07-25 18:13:44 +0000 》
// }

$fileDate.modified.diffHuman()
//= Ex: '3 days ago'

Created Date

Believe it or not, there is no consistent way to get the creation date of a file on Unix-based systems.

The file’s underlying ctime refers to the “inode change time” which is updated when permissions are changed, etc. In some cases, this might be the same as when as the file was created, but is not 100% reliable.

Note: Because this key has a ? (to denote the above ambiguity), you need to use bracket notation [] to access it.

$fileDate = file'files:/some/data.txt'.getDate()

$fileDate['created?']
//= 《 Date 2024-07-25 18:13:44 +0000 》

See Also