18

How do I get the ls command to show its dates and times in UTC, instead of localtime?

I don't want to permanently change the local time for my system to do this.

24

One can set the time zone environment variable for each invocation of ls like so:

TZ=utc ls -l

or set it once with:

export TZ=utc

in a shell to have it always on, for the remaining duration of the shell session.

1
  • 8
    Worth noting that ls -l --full-time will display the full time in ISO format with the offset from UTC.
    – oranja
    May 30 '17 at 8:40
0

To force UTC, set $TZ to UTC:

TZ="UTC" ls <options>

This will set $TZ to UTC just for the duration of this command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.