-1

I want to add days in existing fixed date variable. example I have a variable

2017-12-01 

and I want to add 30 days in it.

I used following command

date -d "2017-12-01+30 days"

but its output is

Sun Dec 31 00:00:00 PKT 2017

and I want to get output like this

2017-12-31 
jww
  • 97,681
  • 90
  • 411
  • 885
iBBi
  • 129
  • 2
  • 12
  • Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. – Cyrus Jul 13 '18 at 04:58
  • I have updated the question with some clarifcations. – iBBi Jul 13 '18 at 05:06
  • 1
    If you are not familiar with Linux man-pages, they provide concise detail on each command usage. For example, you can enter `man 1 date` on the command line to access the man-page for `date`. (they take a bit of making friends with, but it isn't that bad and it is well worth the effort....) They are also available on the web, e.g. [date(1) - man7.org](http://man7.org/linux/man-pages/man1/date.1.html) – David C. Rankin Jul 13 '18 at 05:13

1 Answers1

1

With GNU date:

date -d "2017-12-01 +30 days" '+%F'

Output:

2017-12-31

See: man date

Cyrus
  • 84,225
  • 14
  • 89
  • 153