title: RegExp to match date and time from custom log file
body: <p>I am writing a script that in order to achieve greatness have to convert a date and time format from a log file to a timestamp. I want this for easy comparison later on. </p>
  
  <p>My log file has the format:</p>
  
  <pre><code>2012-11-06 10:32:45
  &lt;log message follows here on multiple lines in XML format&gt; 
  </code></pre>
  
  <p>I am using the following gawk expression to convert my date/time to a timestamp:</p>
  
  <pre><code>$ gawk '/^([0-9]{2,4}-?){3} ([0-9]{2}\:?){3}/{print $0;gsub(/\:/," ");print mktime($0)}' logfile.txt
  </code></pre>
  
  <p>Output will be:</p>
  
  <pre><code>2012-11-01 15:27:28
  1293719248
  </code></pre>
  
  <p>This is actually what I am looking for but the question is if the regexp is correct? Since I am far from a regexp master I would like too know if this is ok or not. Could this be done in a fancier way when it comes to the regexp? The format used in the log file will never change there for I did not bother to make a universal date/time match. Maybe something else in my expression is fubar? :-)</p>