Convert epoch to human readable date & time format

Hello
I have log file from solaris system which has date field converted by Java application using System.currentTimeMillis() function, example is 1280943608380 which equivalent to GMT: Wed, 04 Aug 2010 17:40:08 GMT.
Now I need a function in shell script which will convert 1280943608380 to Wed, 04 Aug 2010 17:40:08.
I used below command but it is giving wrong output: I used
perl -e 'print scalar(gmtime(1280943608380)), "\n"'
but it is giving incorrect output as
Thu Jan 23 20:36:12 2003
Any suggestion? what to do to get correct result?
Thanks in advance

#  perl -e 'print scalar(gmtime(1280943608380/1000)), "\n"'
Wed Aug  4 17:40:08 2010

milliseconds vs seconds :slight_smile:

1 Like

Using ksh93

$ TZ=GMT0 printf "%T\n"  "#$((1280943608380/1000))"
Wed Aug  4 17:40:08 GMT 2010

Thanks!!!!! it worked.........:slight_smile: