Have you ever needed a way to determine UNIX (Epoch) Time, or perhaps its
counterpart in 24 hour format?
via perl:
counterpart in 24 hour format?
via perl:
server [0] perl -e 'print scalar time;' ; echo
1154020678
To use UNIX time to determine it's correlative in 24 hour format:
server [0] perl -e 'print scalar localtime 1154020678 ;' ; echo
Thu Jul 27 13:17:58 2006
via gnu awk:
server [0] gawk 'BEGIN{print systime()}'
1154020897
To use UNIX time to determine it's correlative in 24 hour format:
server [0] awk 'BEGIN{print strftime("%d %b %Y, %H:%M:%S", '1154020897')}'
27 Jul 2006, 13:21:37
via gnu date or /bin/date on FreeBSD:
bsdhost [0] date +%s
1154021261
To use UNIX time to determine it's correlative in 24 hour format:
bsdhost [0] date -r 1154021261
Thu Jul 27 13:27:41 EDT 2006
Update: I've posted a utility, timetrans.pl, that specifically handles time
translations between epoch time and normalized date/time formats.
The utility accepts either TIME as a parameter or as piped input and
allows for input modifiers to further adjust the resulting time output.
Have a look at the link above for examples.
-- troy (04/2012)