Hack 11. Display Future Date and Time

by Ramesh

Following examples shows how to display a future date and time.

  1. $ date
  2. Thu Jan 1 08:30:07 PST 2009
  3.  
  4. $ date --date='3 seconds'
  5. Thu Jan 1 08:30:12 PST 2009
  6.  
  7. $ date --date='4 hours'
  8. Thu Jan 1 12:30:17 PST 2009
  9.  
  10. $ date --date='tomorrow'
  11. Fri Jan 2 08:30:25 PST 2009
  12.  
  13. $ date --date="1 day"
  14. Fri Jan 2 08:30:31 PST 2009
  15.  
  16. $ date --date="1 days"
  17. Fri Jan 2 08:30:38 PST 2009
  18.  
  19. $ date --date="2 days"
  20. Sat Jan 3 08:30:43 PST 2009
  21.  
  22. $ date --date='1 month'
  23. Sun Feb 1 08:30:48 PST 2009
  24.  
  25. $ date --date='1 week'
  26. Thu Jan 8 08:30:53 PST 2009
  27.  
  28. $ date --date="2 months"
  29. Sun Mar 1 08:30:58 PST 2009
  30.  
  31. $ date --date="2 years"
  32. Sat Jan 1 08:31:03 PST 2011
  33.  
  34. $ date --date="next day"
  35. Fri Jan 2 08:31:10 PST 2009
  36.  
  37. $ date --date="-1 days ago"
  38. Fri Jan 2 08:31:15 PST 2009
  39.  
  40. $ date --date="this Wednesday"
  41. Wed Jan 7 00:00:00 PST 2009