Get a unix timestamp from bash
One liner to get a unix timestamp from terminal. Useful for times when you need to pass one in as a URL param.
Now:
date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
A week ago:
date -v-1w -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
A month from now:
date -v+1m -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
Written by Robert Cuadra
Related protips
1 Response
Does not work for me, date does not accept the -j parameter over here.
Try
date +%s
instead. Works great for me and is much shorter.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Terminal
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#