Tuesday 2 July 2013

Epoch time converter

Convert Epoch to Standard Date/Time

# perl -e 'print scalar(localtime(1226424300)), "\n"'
Wed Nov 12 01:25:00 2008

Convert Standard Date/Time to Epoch

# perl -e 'use Time::Local; print timelocal(0,25,1,11,11,2008), "\n";'
1228929900

# perl -e 'use Time::Local; print timegm(0,25,1,11,11,2008), "\n";'
1228958700

For online coversion tools visit Epoch Converter

3 comments:

  1. I am working on Solaris platform . When I run date command it is giving output in PDT format . So above commands are not working fine with my system .Please suggest any solution .

    ReplyDelete
  2. You can try this "truss" command

    #truss /usr/bin/date 2>&1 | grep ^time | awk -F"= " '{print $2}'

    if awk is not working use nawk .

    ReplyDelete
  3. what if I have to convert from epoch to regular date like 1403802435 to yyyymmdd format? thanks in advance

    ReplyDelete