Created
September 19, 2012 11:12
-
-
Save CodeNegar/3749097 to your computer and use it in GitHub Desktop.
PHP: mysql date to unix timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mysql_to_unix($time = '') | |
{ | |
// YYYY-MM-DD HH:MM:SS | |
$time = str_replace(array('-', ':', ' '), '', $time); | |
// YYYYMMDDHHMMSS | |
return mktime( | |
substr($time, 8, 2), | |
substr($time, 10, 2), | |
substr($time, 12, 2), | |
substr($time, 4, 2), | |
substr($time, 6, 2), | |
substr($time, 0, 4) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment