Hack 10. Display Past Date and Time

by Ramesh

Following are various ways to display a past date and time:

  1. $ date --date='3 seconds ago'
  2. Thu Jan 1 08:27:00 PST 2009
  3.  
  4. $ date --date="1 day ago"
  5. Wed Dec 31 08:27:13 PST 2008
  6.  
  7. $ date --date="1 days ago"
  8. Wed Dec 31 08:27:18 PST 2008
  9.  
  10. $ date --date="1 month ago"
  11. Mon Dec 1 08:27:23 PST 2008
  12.  
  13. $ date --date="1 year ago"
  14. Tue Jan 1 08:27:28 PST 2008
  15.  
  16. $ date --date="yesterday"
  17. Wed Dec 31 08:27:34 PST 2008
  18.  
  19. $ date --date="10 months 2 day ago"
  20. Thu Feb 28 08:27:41 PST 2008