COPYRIGHT RESERVED 2009 BY MAX TSAI



Visit Max Tsai at Facebook | Twitter | atom

Sunday, March 9, 2008

UNIX date -- it is easier than you think!

So, if you need a past or future date from today, UNIX date command makes it a piece of cake. I was asked by a friend on this:

28 days ago

Linux:
date --date='28 days ago' +%Y%m%d

OS X:
date -r $((`date +%s` - 2419200)) +%Y%m%d

I have not tried it, but it should work on FreeBSD:
date -v -28d +%Y%m%d

No comments:

Post a Comment