<p>I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious?</p>

[{'answer_id': 20605, 'author': 'Ross', 'author_id': 2025, 'author_profile': 'https://Stackoverflow.com/users/2025', 'pm_score': 5, 'selected': True, 'text': '<p>Converting from timestamp to format:</p>\n\n<pre><code>date(\'Y-m-d\', $timestamp);\n</code></pre>\n\n<p>Converting from formatted to timestamp:</p>\n\n<pre><code>mktime(0, 0, 0, $month, $day, $year, $is_dst);\n</code></pre>\n\n<p>See <a href="http://www.php.net/manual/en/function.date.php" rel="noreferrer">date</a> and <a href="http://www.php.net/manual/en/function.mktime.php" rel="noreferrer">mktime</a> for further documentation.</p>\n\n<p>When it comes to storing it\'s up to you whether to use the MySQL DATE format for stroing as a formatted date; as an integer for storing as a UNIX timestamp; or you can use MySQL\'s TIMESTAMP format which converts a numeric timestamp into a readable format. <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html" rel="noreferrer">Check the MySQL Doc</a> for TIMESTAMP info.</p>\n'}, {'answer_id': 20607, 'author': 'Nate Smith', 'author_id': 1238, 'author_profile': 'https://Stackoverflow.com/users/1238', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://ca.php.net/manual/en/function.strtotime.php" rel="nofollow noreferrer">strtotime()</a> and <a href="http://ca.php.net/manual/en/function.getdate.php" rel="nofollow noreferrer">getdate()</a> are two functions that can be used to get dates from strings and timestamps. There isn\'t a standard library function that converts between MySQL and PHP timestamps though.</p>\n'}, {'answer_id': 20608, 'author': 'Yaakov Ellis', 'author_id': 51, 'author_profile': 'https://Stackoverflow.com/users/51', 'pm_score': 0, 'selected': False, 'text': '<p>Use the PHP <a href="http://il2.php.net/date" rel="nofollow noreferrer">Date</a> function. You may have to convert the mysql timestamp to a Unix timestamp in your query using the <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html" rel="nofollow noreferrer">UNIX_TIMESTAMP</a> function in mysql.</p>\n'}, {'answer_id': 20668, 'author': 'Jake McGraw', 'author_id': 302, 'author_profile': 'https://Stackoverflow.com/users/302', 'pm_score': 0, 'selected': False, 'text': "<p>A date string of the form:</p>\n\n<pre><code>YYYY-MM-DD\n</code></pre>\n\n<p>has no time associated with it. A MySQL Timestamp is of the form:</p>\n\n<pre><code>YYYY-MM-DD HH:mm:ss\n</code></pre>\n\n<p>to compare the two, you'll either have to add a time to the date string, like midnight for example</p>\n\n<pre><code>$datetime = '2008-08-21'.' 00:00:00';\n</code></pre>\n\n<p>and then use a function to compare the epoc time between them</p>\n\n<pre><code>if (strtotime($datetime) &gt; strtotime($timestamp)) {\n    echo 'Datetime later';\n} else {\n    echo 'Timestamp equal or greater';\n}\n</code></pre>\n"}, {'answer_id': 30471, 'author': 'jonthornton', 'author_id': 3250, 'author_profile': 'https://Stackoverflow.com/users/3250', 'pm_score': 2, 'selected': False, 'text': "<p>You can avoid having to use <code>strtotime()</code> or <code>getdate()</code> in <strong>PHP</strong> by using MySQL's <code>UNIX_TIMESTAMP()</code> function.</p>\n\n<pre><code>SELECT UNIX_TIMESTAMP(timestamp) FROM sometable\n</code></pre>\n\n<p>The resulting data will be a standard integer Unix timestamp, so you can do a direct comparison to <code>time()</code>.</p>\n"}, {'answer_id': 635809, 'author': 'St. John Johnson', 'author_id': 76734, 'author_profile': 'https://Stackoverflow.com/users/76734', 'pm_score': 2, 'selected': False, 'text': '<p>I wrote this little function to simplify the process: </p>\n\n<pre><code>/**\n * Convert MySQL datetime to PHP time\n */\nfunction convert_datetime($datetime) {\n  //example: 2008-02-07 12:19:32\n  $values = split(" ", $datetime);\n\n  $dates = split("-", $values[0]);\n  $times = split(":", $values[1]);\n\n  $newdate = mktime($times[0], $times[1], $times[2], $dates[1], $dates[2], $dates[0]);\n\n  return $newdate;\n}\n</code></pre>\n\n<p>I hope this helps</p>\n'}]
['https://Stackoverflow.com/questions/20598', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/572/']