Skip to content

Instantly share code, notes, and snippets.

@CodeNegar
Created September 19, 2012 11:12
Show Gist options
  • Save CodeNegar/3749097 to your computer and use it in GitHub Desktop.
Save CodeNegar/3749097 to your computer and use it in GitHub Desktop.
PHP: mysql date to unix timestamp
<?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