Printing previous dates with the FreeBSD date utility

In a previous post, I described how to get the date for a day in the past. This method unfortunately doesn’t work on FreeBSD hosts, since FreeBSD doesn’t come with the GNU date utility. As an alternative to GNU date, you can pass a time value to the date utilities “-v” option to print a date in the past:

$ date -v-2d
Mon Jan 1 13:02:57 EST 2007

I think I prefer the GNU date syntax, but this seems to work pretty well.

This article was posted by Matty on 2007-01-04 14:14:00 -0400 -0400