Skip to content

Instantly share code, notes, and snippets.

@viniciusgonmelo
Last active June 13, 2023 02:37
Show Gist options
  • Save viniciusgonmelo/9817dc51bff47159e18fd638528e8389 to your computer and use it in GitHub Desktop.
Save viniciusgonmelo/9817dc51bff47159e18fd638528e8389 to your computer and use it in GitHub Desktop.
Converte epoch para data e hora
#!/usr/bin/env bash
# Script: epoch-datetime.bash
# Descrição: Converte epoch para data e hora
# para obter epoch: date +%s
# Uso: ./epoch-datetime EPOCH
# Checa o número de argumentos e verifica se é um número
if [ $# -ne 1 ] || ! [[ $1 =~ ^[0-9]+$ ]]; then
echo "Erro: Uso incorreto. Correto: ${0} EPOCH"
exit 1
fi
EPOCH=$1
# Converte epoch para data e hora
DATE=$(date -d @"${EPOCH}" +'%d/%m/%Y - %H:%M:%S')
echo "${DATE}"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment