how to interconversion between timestamps and date time on MacOS X

#0 Get current timestamps
Put those lines in your .zshrc or bashrc

alias showmeCurrentTimestamp="date +%s"

Then you need execute one command below

source ~/.zshrc|| source ~/.bashrc

#1 Timestamps to date
Save this script in anywhere you want and then make a soft link to ‘/usr/local/bin’ just like “ln -s source dst”

#!/bin/bash
#auth:codewalker 
#mail:simon.xie@codewalker.me
if [ $# -eq 1 ];then
	date -r $1
else
	echo "Usage: $0 [timestamp]"
	date -r $(date +%s)
fi

EOF

发表评论

电子邮件地址不会被公开。 必填项已用*标注