2009-04-03

freebsd - convert unix epoch date and time using the date command

Epoch dates are seconds started from 1st January, 1970. It is a common date and time representation, especially in unix and linux world. It provides a way to convert time stamp in a much easier way for programming calculation, an integer. Below are one of the way to convert epoch timestamps to a readable format :

syntax :
date -j -f 'specification of input format 'input date and/or time' +%s

specification of input format = how is the date being define by you for "date" command to process
input date and/or time = are the digits input by you for "date" to calculate

e.g.
date -j -f '%Y%m%d-%H%M%S' '20090401-000000' +%s
and you shall get your epoch time (in seconds) after pressing enter.

Ciao !!!

No comments: