title: How to format date for tar backup?
body: <p>So I have a <code>bash</code> script that I need to run weekly but I don't know how to format the date so I can automate the script.</p>
  
  <p>My script:</p>
  
  <pre><code>#!/bin/bash
  
  
  tod=$(date +%F_%H%M%S)
  echo "start"
  echo $tod
  
  tar --newer-mtime=20130811 -cvzf /path/to/file/xz$tod-last6months.tar /path/to/what/I'm/tarring
  
  echo "done"
  exit
  </code></pre>
  
  <p>I want to replace the <code>mtime=20130811</code> with something similar to the <code>tod=$(date +%F_%H%M%S)</code> so I don't have to manually change the date and so it will only <code>tar</code> what has changed over the last 6 months.</p>
  
  <p>Thanks in advance.</p>