Convert Epoch to Standard Date/Time
# perl -e 'print scalar(localtime(1226424300)), "\n"'
Wed Nov 12 01:25:00 2008
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
1228929900
# perl -e 'use Time::Local; print timegm(0,25,1,11,11,2008), "\n";'
1228958700
For online coversion tools visit Epoch Converter
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 .
ReplyDeleteYou can try this "truss" command
ReplyDelete#truss /usr/bin/date 2>&1 | grep ^time | awk -F"= " '{print $2}'
if awk is not working use nawk .
what if I have to convert from epoch to regular date like 1403802435 to yyyymmdd format? thanks in advance
ReplyDelete