You might need to get a timestamp of yesterday in any script.


Do not think about any scripting and converting dates. Just use the old good ‘date’ command.


This script should be self explanatory:

set -o verbose on
date --date=now
date --date=today # same thing
date --date='3 seconds'
date --date='3 seconds ago'
date --date='4 hours'
date --date='tomorrow'
date --date='1 day'
date --date='1 days'
date --date='yesterday'
date --date='1 day ago'
date --date='1 days ago'
date --date='1 week'
date --date='1 fortnight'
date --date='1 month'
date --date='1 year'
Timestamp of yesterday using ‘date’ command
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *