Sunday, October 9, 2022

[SOLVED] Get the date (a day before current time) in Bash

Issue

How can I print the date which is a day before current time in Bash?


Solution

Sorry not mentioning I on Solaris system. As such, the -date switch is not available on Solaris bash.

I find out I can get the previous date with little trick on timezone.

DATE=`TZ=MYT+16 date +%Y-%m-%d_%r`
echo $DATE


Answered By - conandor
Answer Checked By - Robin (WPSolving Admin)