-
-
Save lexrus/2041751 to your computer and use it in GitHub Desktop.
Epoch / Unix Timestamp Converter
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
#!/bin/bash | |
# sudo chmod +x tc;sudo mv tc /usr/bin | |
if [[ -z "$1" ]] | |
then | |
printf %s "\ | |
Nifty Timestamp Convertor by Lex Tang | |
tc 2012/12/12 | |
tc 1355283413 | |
" | |
exit | |
fi | |
if [[ "$1" == *"/"* ]] | |
then | |
s=$(date -j -f "%Y/%m/%d" "$1" "+%s") | |
else | |
s=$(ruby -e "puts Time.at($1).strftime('%Y-%m-%d %H:%M:%S %z')") | |
fi | |
echo $s | |
echo $s | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment