Using the date command to adjust date/time

The FreeBSD date command supports adjusting time/date using the -v [+|-]val[y|m|w|d|H|M|S] option.
Reading 'man date' carefully shows -v only works on the current time, not a command line provided date/time.

Question: Are there any command line (bash script) utilities on FreeBSD that can do date/time adjusting on a command line provided date/time

Kind regards,
Peter
 
Last edited by a moderator:
The date command as shown in the 3rd synopsis should do what you are looking for. The combination of the -j option and the new_date provides a way to provide the 'starting date/time' without actually setting the system clock, and the -v will do the requested adjustment to that and print it.
 
You mean something like this?
$ date -j -v1d -v+13m -v-1d -v-fri 202812300000 Fri Dec 28 00:00:00 PST 2029
All the arithmetic is in relation to 202812300000 or 30-Dec-2028 00:00. Something like last friday of the same month (Dec) but a year from 2028.
 
Back
Top