Javascript: Convert date to UTC format
<p>I have the following date in UTC format:
<code>2016-06-18T05:18:27.935Z</code></p>

<p>I am using the code below to convert it to the following format <code>2016-06-18 05:18:27
</code> so I can compared it in <code>MySQL</code> database against <code>updatedAt</code> column.</p>

<pre><code>var date = new Date(lastRequest);
date = date.getUTCFullYear() + '-' +
    ('00' + (date.getUTCMonth() + 1)).slice(-2) + '-' +
    ('00' + date.getUTCDate()).slice(-2) + ' ' +
    ('00' + date.getUTCHours()).slice(-2) + ':' +
    ('00' + date.getUTCMinutes()).slice(-2) + ':' +
    ('00' + date.getUTCSeconds()).slice(-2);
</code></pre>

<p>I need to get the date of the last record and convert its date back to UTC format.  </p>

<p>Basically, how do I go from the following format: <code>2016-06-18 05:18:27</code> back to UTC?</p>