1

for example , below example is simple. DATE=$(date -v-7d ) echo $DATE

but how to calculate

2019-02-28 00:00:00  - or +  01:30:00 # date&time - or +  time 

or

2019-02-28 00:00:00  - or + 2019-02-20 13:30:35 # date&time - or + date&time

thanks

cool jobs
  • 103
  • 9

1 Answers1

0
 date; date --date="5 hours ago 55 minutes ago 40 seconds ago " +%H%M-%d%m%Y

In this way you can add or subtract from the current time

Aman Gupta
  • 400
  • 1
  • 9
  • does't works in unix terminal with bash . – cool jobs Feb 23 '19 at 11:34
  • It does if you have the same version of the `date` command. Which OS or shell you use doesn't really matter for this. The options look like GNU `date`, which is standard on most Linux platforms, and easy to install on basically every other system. If you require compatibility with e.g. BSD `date` (which is what you get out of the box on e.g. MacOS) or Busybox, you shoud probably say so. – tripleee Feb 23 '19 at 11:39
  • for example , BSD / UNIX : date -v-7d – cool jobs Feb 23 '19 at 11:46
  • LINUX : date -d-"7days" so different many options – cool jobs Feb 23 '19 at 11:54
  • please let me know not from current time but from specific date& time for + or - operations . – cool jobs Feb 24 '19 at 03:18