I have used the below commands to find the 30 mins older time but not able to frame commands to add 30 mins.
Sample structure of input.
dateinput=20181214202959
inputTime=$(echo $dateinput | sed 's,\(.\{4\}\)\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)\(.\{2\}\),\1-\2-\3 \4:\5:,')
param2=`date '+%Y%m%d%H%M%S' --date="$inputTime 30 minutes ago"`
echo $param2
20181214195959
Please let me know the steps to add 30 mins similar to the above one. For the sample dateinput given above the desired output is 20181214205959.
With the direct date command I am able to add and reduce based on the requirement like given below :
$date
Tue Dec 18 20:49:06 PST 2018
$date --date "-30 minutes"
Tue Dec 18 20:18:55 PST 2018
$date --date "+30 minutes"
Tue Dec 18 21:19:01 PST 2018
But my requirement is to get the date from the input which will be given like 20181214202959 which is in YYYYMMDDhhmmss format. This is where I am facing issues. Able to reduce the time using "30 minutes ago" command but not able to get the future value for the given time.