3 ms·
Is there an equivalent command for doing things like 147 days from today or days since 21 jun 2021 or 88 days after 15 Aug 2021? This is the one thing I really
by dhosek 5y ago
Is there an equivalent command for doing things like 147 days from today or days since 21 jun 2021 or 88 days after 15 Aug 2021? This is the one thing I really wish was in Spotlight (I use spotlight for unit conversion and calculations which is really handy).
- mark-r 5y agoI use the Python datetime module for stuff like that. Excel can be useful too, since it treats dates as a number of days.
- spiffytech 5y agoWolframAlpha works well for those types of calculations.
- pajko 5y agohttps://www.timeanddate.com/date/dateadded.html https://www.timeanddate.com/date/dateadded.html
- dhosek 5y agoTo clarify, I was thinking a quick command line thing. Right now, I do it in a browser (both DuckDuckGo and Google produce the answer easily enough).
- zadwang 5y agoThe unix date command does this.
- randomswede 5y agoWell, GNU date does, BSD date may or may not. Linux box: $ date -d 'now + 4711 days ago' Thu Nov 6 06:57:20 UTC 2008 $ date --version date (GNU coreutils) 8.30 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by David MacKenzie. Mac: % date -d 'now + 4711 days ago' usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format] I also seem to be unable to pull a version out of the Mac's date command.
- bewuethr 5y agoWith GNU date (but not the BSD-based macOS date, I believe), and not all that convenient for "days since": $ date -d 'today + 147 days' +%F 2022-02-23 $ echo $(( ($(date +%s) - $(date -d '2021-06-21' +%s)) / 86400 )) 100 $ date -d '2021-08-15 + 88 days' +%F 2021-11-11