title: How to convert a bash string into a date?
body: <p>I have a file which contains a string:</p>
  
  <pre><code>2014-11-22 08:15:00
  </code></pre>
  
  <p>... which represents <code>Nov 22 2014 @ 8:15 AM</code>.</p>
  
  <p>I want to parse this string and use it with the date function in BASH to compare with the current date. 
  I have code that compares dates but both dates are generated by BASH and it's easy to format and compare. However, I can't use the string (which is collected from another system) to compare. </p>
  
  <p>I've tried stuff like:</p>
  
  <pre><code>$ mydate=$(cat filewithstring);date -d $mydate
  $ mydate=$(cat filewithstring);date -d '$mydate'
  $ mydate=$(cat filewithstring);date -d $mydate "+%Y-%m-%d %H:%M:%S"
  </code></pre>
  
  <p>I end up with errors like:</p>
  
  <blockquote>
    <p>date: the argument ‘08:00:00’ lacks a leading '+'; when using an
    option to specify date(s), any non-option argument must be a format
    string beginning with '+'*</p>
  </blockquote>
  
  <p>...or...</p>
  
  <blockquote>
    <p>date: extra operand ‘+%Y-%m-%d %H:%M:%S’</p>
  </blockquote>
  
  <p>I know that if I type in the string explicitly, it works fine:</p>
  
  <pre><code>$ date -d '2014-11-22 08:15:00'
  Sat Nov 22 08:15:00 EST 2014
  </code></pre>
  
  <p>In the end, I'm hoping to do the following:</p>
  
  <ul>
  <li>capture and collect the date/time string in the file from the "other" server</li>
  <li>read the string in the file</li>
  <li>compare that date/time in the string with the current date/time</li>
  <li>output something like "This event processed 12 minutes ago"</li>
  </ul>
  
  <p>Any ideas?  Thanks.</p>