Skip to content

Instantly share code, notes, and snippets.

@lexrus lexrus/tc
Created Mar 15, 2012

Embed
What would you like to do?
Epoch / Unix Timestamp Converter
#!/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
You can’t perform that action at this time.