MySQL NOW()
Using this function you can get the current date and time in the MySQL NOW() form, in case you want to use PHP to generate it, instead of MySQL.
function mysql_now() {
$temp = getdate();
$date = $temp['year'] . "-";
if (strlen($temp['mon']) == 1) {
$date .= "0" . $temp['mon'];
} else {
$date .= $temp['mon'];
}
$date .= "-";
if (strlen($temp['mday']) == 1) {
$date .= "0" . $temp['mday'];
} else {
$date .= $temp['mday'];
}
$date .= " ";
if (strlen($temp['hours']) == 1) {
$date .= "0" . $temp['hours'];
} else {
$date .= $temp['hours'];
}
$date .= ":";
if (strlen($temp['minutes']) == 1) {
$date .= "0" . $temp['minutes'];
} else {
$date .= $temp['minutes'];
}
$date .= ":";
if (strlen($temp['seconds']) == 1) {
$date .= "0" . $temp['seconds'];
} else {
$date .= $temp['seconds'];
}
return $date;
}
?>