title: How to convert date string to epoch timestamp with the OS X BSD `date` command?
body: <p>I have a date string in the following format <code>Jul 27 23:59:59 2016 GMT</code> and I need to convert it to the equivalent epoch timestamp with the OS X BSD <code>date</code> command.</p>
  
  <p>GNU <code>date</code> has a nice <code>-d</code>/<code>--date=STRING</code> argument:</p>
  
  <pre><code>$ date -d "Jul 27 23:59:59 2016 GMT" +'%s'
  1469663999
  </code></pre>
  
  <p>The BSD <code>date</code> command on OSX sadly has no such option.</p>
  
  <p><code>date -j -f "&lt;FORMAT&gt;" "Jul 27 23:59:59 2016 GMT" +'%s'</code> seems to be the way to go, but I can't find the write format string. <a href="https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/date.1.html" rel="noreferrer">Apple's man page</a> states:</p>
  
  <pre><code>date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
  
  can be used to parse the output from date and express it in Epoch time.
  </code></pre>
  
  <p>But that doesn't appear to be true:</p>
  
  <pre><code>$ date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
  Failed conversion of ``Wed 13 Jul 2016 11:17:49 BST'' using format ``%a %b %d %T %Z %Y''
  date: illegal time format
  usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
          [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
  </code></pre>
  
  <p>How can I convert a date string in this format to an epoch timestamp with the OS X BSD <code>date</code> command?</p>
  
  <hr>
  
  <p>I can't seem to get a version out of <code>date</code>, but I'm on OS X <code>10.11.5</code> (El Capitan) if that's significant.</p>