Sometimes UNIX timestamps can be easier to manage than MySQL datetimes. Here’s a function from converting one to the other.

1
2
3
4
5
6
7
8
function convert_datetime_to_timestamp($datetime)
{
  list($date, $time) = explode(" ", $datetime);
  list($year, $month, $day) = explode("-", $date);
  list($hours, $minutes, $seconds) = explode(":", $time);

  return mktime($hours, $minutes, $seconds, $month, $day, $year);
}