Skip to content

Instantly share code, notes, and snippets.

@OMGVee
Created August 28, 2013 19:07
Show Gist options
  • Save OMGVee/6369960 to your computer and use it in GitHub Desktop.
Save OMGVee/6369960 to your computer and use it in GitHub Desktop.
<?
$timestamp = explode(" ", "08-27-13 05:45 pm");
$datestring = $timestamp[0];
$timestring = $timestamp[1];
$meridian = $timestamp[2];
$date = explode("-", $datestring);
$day = $date[1];
$month = $date[0];
$year = $date[2];
$time = explode(":", $timestring);
if ($meridian == 'pm') {
$hour = $time[0] + 12;
} else {
$hour = $time[0];
}
$min = $time[1];
$outputdateinfuckingmysqlformat = date('Y-m-d H:i', mktime($hour, $min, 0, $month, $day, $year));
echo $outputdateinfuckingmysqlformat;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment