Last active
June 13, 2023 02:37
-
-
Save viniciusgonmelo/9817dc51bff47159e18fd638528e8389 to your computer and use it in GitHub Desktop.
Converte epoch para data e hora
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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