Your ICT partner

How to convert epoch time to UNIX time format

How to convert epoch time to UNIX time format

While during a swverify command I came across the following error:

$ swverify PHKL_34161
ERROR:   File "/opt/fcms/bin/fcmsutil" should have mtime "1138964905"
         but the actual mtime is "1400486913".

Nice error, but that does not tell me which date format to use with the command touch, as

$ touch -m -t 1138964905 /opt/fcms/bin/fcmsutil
date: bad conversion

Found a few methods that produced the output I was looking for on:

HP-UX: $ echo 0d1138964905=Y | adb
       2006 Feb  3 12:08:25

HP-UX/Linux: $ perl -le 'print scalar localtime(1138964905)'
             Fri Feb  3 12:08:25 2006

Linux: $ echo 1138964905 | awk '
       {printf("%s", strftime("%Y.%m.%d ",$1));
       printf("%s", strftime("%H:%M:%S \n",$1));
       }'
       2006.02.03 12:08:25

Ok, we have now the date - using touch to modify the date:

 $ touch -m -t 200602031208.25 /opt/fcms/bin/fcmsutil
 $ swverify PHKL_34161

The swverify command is now very happy with the correct date.

External Links:


« How to fix git HEAD detached from a branch |  »

Comments

comments powered by Disqus