Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 8
    -m for changing modification time. Commented Apr 13, 2014 at 12:23
  • 7
    In Yosemite, touch required me to use the format +%Y%m%d%H%M.%S (notice the dot between minutes and seconds) Commented Apr 27, 2015 at 9:39
  • 1
    To be explicit, this sets the creation time (-d) of file.txt from the modification time (-m) of test.txt. If you want the creation time of test.txt to be copied, use -d in both places. Commented Jul 29, 2022 at 19:04
  • 1
    What time zone are these strings? Commented Apr 28, 2024 at 9:59
  • 1
    @SamGinrich SetFile and GetFileInfo use the current system timezone. I discovered that you can change that behaviour using the TZ environment variable. E.g. with EST (UTC-05:00): TZ=+05:00 SetFile -d '12/31/1999 23:59:59' file.txt will set the creation date to 2000-01-01T04:59:59Z (note the inverted sign in TZ compared to usual convention!) Commented Jun 2, 2024 at 2:29