Tune2fs: what time zone is the date created in and is it possible to change it

datee2fsprogs

I have been using tune2fs to determine the age of my Linux distribution installations but without knowing the time zone the date in it is less useful. The exact command I am using is from here, here it is just for the sake of clarity:

sudo tune2fs -l /dev/sda3 | grep created | sed 's/.*created\:\s*//g'

but the output is of the form:

Fri Jun 23 23:59:22 2017

Note how there is no time zone mentioned. But date returns output of the form:

Sun Jul 23 17:58:18 AEST 2017

Notice how the time zone AEST is mentioned. I have read the man page of tune2fs. I have searched for "date", "created", "time" in it using my Web browser's find utility and I haven't found a single mention of the time zone of the date format, or if there is a way to manually set it. I have run DuckDuckGo searches for "tune2fs date" and "tune2fs timezone" and I looked at the top five results and couldn't find anything relevant in them.

Best Answer

The date seems to be displayed in the local system time zone at the time it was created.

e.g. my /boot partition is ext4 on raid-1 (/dev/md0), created when I replaced my boot drives with 4 SSDs and converted to root on ZFS last year. I kept a /boot ext4 partition in case of emergency.

# tune2fs -l /dev/md0 | sed -n -e 's/.*created\:\s*//gp'
Sat Oct  8 16:38:45 2016

# TZ=UTC tune2fs -l /dev/md0 | sed -n -e 's/.*created\:\s*//gp'
Sat Oct  8 05:38:45 2016

I'm also on the east coast of Australia (Melbourne), and the difference between 16:38 and 05:38 is 11 hours, which is correct for AEDT (daylight savings starts in October for those states which observe it)


BTW, it's almost never necessary to pipe the output of grep into either sed or awk. both can already do regexp pattern matches. an awk example might look like this:

# tune2fs -l /dev/md0 | awk -F': +' '/created/ {print $2}'
Sat Oct  8 16:38:45 2016
Related Question