linuxshellunix

How can we add a day into date with given format in unix/linux


Date Format - 2025-11-03T20:39:00+05:30

I need to take this date into a variable, add 24hrs to it and store into another variable. Suggestions are appreciable as I'm new to linux coding.


Solution

  • Use date command:

    save to variable:

    $ export savedDate=2025-11-03T20:39:00+05:30
    

    add 24hrs to savedDate and store it:

    $ export updatedDate=$(date -d "$savedDate + 1 day" +"%Y-%m-%dT%H:%M:%S+5:30")
    

    show result:

    $ echo $savedDate && echo $updatedDate 
    

    for more information, use:

    $ date --help