4

I am getting invalid date format 2011 when I try to the modified time, this works fine without the seconds

touch -t 2011 08 23 14 05 14 voucher.tpl

I am a little confused with the below that explains how to do this:

-t time specifies a particular time using this format:

[[[[cc]yy]MM]dd]hhmm[.ss]

where cc is the optional first 2 digits of the year, yy is the optional last 2 digits of the year, MM is the optional number of the month (01-12), dd is the optional day of the month, hh is the hour in 24 hour format (required), mm is the minutes (required), ss is the optional seconds.

4 Answers 4

7
$ touch -t 201108231405.14 voucher.tpl
$ ls -l --time-style='+%B %d %H:%M:%S' voucher.tpl
-rw-r--r-- 1 quanta quanta 0 August 23 14:05:14 voucher.tpl
1
  • $ /bin/touch -m -t 201903100248.11 2019-03-10-02-48-03.nef <br> /bin/touch: invalid date format ‘201903100248.11’ <br> apparently there is hidden magic, too?
    – Bruce
    Mar 29, 2019 at 15:16
4

Remove spaces. Also, you're missing the period between the mm and the ss. This will work:

touch -t 201108231405.14 voucher.pl
2

touch -t 201108231405.14 voucher.tpl should work. It did for me.

Note that the time format specification does not include any spaces.

2

You are using the wrong format.

This should work fine:

touch -t 201108231405.14 voucher.tpl

-t STAMP

use [[CC]YY]MMDDhhmm[.ss] instead of current time

Not the answer you're looking for? Browse other questions tagged .