timedatectl set-time X days
timedatectl set-time 2021-01-05
The above code works fine but how to add +x days instead for the exact time through the command line.
Solution 1:
The timedatectl
command only accepts specific times. However, you can get around this by using date
to generate the time:
$ date
Thu Dec 23 03:00:18 PM EET 2021
$ date -d 'now + 5 days'
Tue Dec 28 03:00:18 PM EET 2021
$ date -d 'now + 5 days' +%F
2021-12-28
So to set the date to something 5 days in the future, use:
timedatectl set-time $(date -d "now + 5 days" +%F)