Is there a way to calculate a time stamp for the next coming up of a week day?
So for instance, with friday, i'd like to be able to run some code that calculates that from today Wednesday 19/05/10, the next friday will be 21/05/10 and get a time stamp from it.
I know the date command can parse a given string date according to a format, but I can't figure out how to calculate "next friday from today"
Any idea?
EDIT: I'm on a mac
If you don't have GNU date, you can use the built-in date command with the -v option. returns tomorrow's date. returns tomorrow's date in the format YYYY-MM-DD.
To get yesterday's date in bash shell you can use the Linux GNU date version with date -d yesterday or the Unix/macOS date version using date -j -v -1d .
With GNU date:
date -d 'this Friday' '+%d/%m/%y'
See Relative items in date strings, part of the GNU date documentatoin. There are also examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With