Set a specific timestamp with touch -t
Most people only use touch to create empty files, but its -t flag rewrites modification and access times to any date you specify in a compact 10+ digit format.
Run `touch -t 202601150830 report.txt` to stamp the file as modified January 15, 2026 at 08:30.
01Command
Command
$ touch -t 202601150830 report.txt
ls -l report.txt02What it does
The -t argument format is [[CC]YY]MMDDhhmm[.SS]: month, day, hour, and minute are required, the century/year is optional, and seconds follow an optional dot. On macOS, touch -t affects modification and access times, while creation date requires other tools — a distinction that surprises people migrating from other Unixes.
03Risk
!Warning: Time-stamped files can confuse backup tools and Spotlight's date-based sorting; don't rewrite timestamps on files inside backup or library folders.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- touch — change file timestamps (macOS)Evidence: Documents the -t option's [[CC]YY]MMDDhhmm[.SS] format.
Last verified: 2026-09-17 · Category: Files & Folders