Code

Convert MySQL Timestamp Format to UNIX Timestamp

Of course, you can usually do this within your MySQL query, but just in case you need it externally...

<?php
function convertTimestamp($timestamp) {
    $year = substr($timestamp,0,4);
    $month = substr($timestamp,5,2);
    $day = substr($timestamp,8,2);
    $hour = substr($timestamp,11,2);
    $minute = substr($timestamp,14,2);
    $second = substr($timestamp,17,2);
    return mktime($hour,$minute,$second,$month,$day,$year) ;
    }
?>

Last updated on November 8, 2009.

Copyright © 2010, Ink Plant. All rights reserved.