Mostrando entradas con la etiqueta shell script datetime date. Mostrar todas las entradas
Mostrando entradas con la etiqueta shell script datetime date. Mostrar todas las entradas

miércoles, 17 de junio de 2009

Days between 2 unix epoch


#!/bin/bash
# Calculate "days diff" (unix epoch)
function daysdiff {
begin=${1:-0}
end=${2:-0}
let Sec=$end-$begin

if ((Sec < 0)); then
echo $((Sec/-86400))
else
echo $((Sec/86400));
fi
return 0
}

Working with date in shell

If you don't know what time is the unix time 1245257034



Or in UTC


$ date -d @1245257034 -u
Wed Jun 17 16:43:54 UTC 2009


To know what is the current unix time in your machine

$ date +%s
1245257175