Owen Dawson Owen Dawson - 2 months ago 7x
MySQL Question

mysqli time & date insert

I'm trying to insert the date that a user registered on a site into mysql but for some odd reason im not getting it insert right, Im using this query below

$connect->query("INSERT INTO `users` (username, email, password, name, country, signup_date) VALUES ('". $username ."', '". $email ."', '". $password ."', '". $fname . " " . $lname ."', '". $country ."', '".time()."')");

I'm getting an amount insert into the signup_date but its obviously jumbled up, any ideas?


Php's time() function returns the unix timestamp. However, MySQL expects date and time values to be provided in 'YYYY-MM-DD HH:MM:SS' format. Just format your time value within php to match the format MySQL expects.