4 ms·
The date command can also answer this question: $ date -d 'march 12 2019 + 366 days' Thu Mar 12 00:00:00 PDT 2020
by schoen 7y ago
The date command can also answer this question:
$ date -d 'march 12 2019 + 366 days'
Thu Mar 12 00:00:00 PDT 2020
- skratlo 7y agopure gold buddy, thanks for this
- tus88 7y agoI starting thinking about the Python equivalent of this and it was disgusting.
- michael_j_ward 7y agoThis? $ python -c 'import datetime; print(datetime.date(2019, 3, 12) + datetime.timedelta(days=366))' 2020-03-12
- fouc 7y agoRuby isn't much better ruby -e "require 'date'; puts (Date.parse('march 12 2019') + 366)" 2020-03-12
- dredmorbius 7y agoFor GNU date, yes. BSD not so much (default on MacOS). MacOS$ date -d 'now + 30 days' usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]GNU$ date -d 'now +30 days' GNU$ date -u -d 'now +30 days' Sun Apr 5 18:55:12 UTC 2020 (In BSD date, the '-d' argument "Set the kernel's value for daylight saving time.")
- thewebcount 7y agoassuming you're on Unix
- ferzul 7y agoyou could be running gnu/linux or windows with msys, neither of which are unix
- zaat 7y agoIf you are on Windows, (or if you are on Linux but for some reason still runs) in PowerShell: > (Get-Date).AddDays(365)
- ringshall 7y agoOr excel, rc[-1]+366, assuming you typed in the date you want in the cell to the left...