Hello
First, sorry for the English if it’s bad …
I m working in localhost ( XAMPP ) php version is 5.4.4, and PHPmyAdmin v3.5.2
this problem is complicated, is about storing time in SQL table, here is the php code that I use to store time
if (mysql_query('insert into users (username, password, email, regdate) values ("'.$username.'", "'.$password.'", "'.$email.'", "'.time().'")')){
echo 'SQL Inserted !';
}
else { echo 'Error'; }
and this is the SQL table
CREATE TABLE `users` (
`id` bigint(20) NOT NULL auto_increment,
`username` varchar(256) NOT NULL,
`password` varchar(256) NOT NULL,
`email` varchar(256) NOT NULL,
`regdate` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
and finally
$user_req = mysql_query("SELECT * FROM users WHERE id='$user_id'");
if(mysql_num_rows($user_req)>0){
$user_info = mysql_fetch_array($user_req);
echo 'username : ' . $user_info['username'] . '<br/>';
echo 'User since : ' . date('d/m/Y H:i a',$user_info['regdate']) . '<br/>';
}
the problem here is that if the registration time is 30/07/2015 01:04 am
The output goes like this 30/07/2015 03:04 am
I don’t know from where the 2 hours came from, any way I tried in another script, I’ve even reinstall XAMPP, but didn’t work.
I also tried to use ’ timestamp ’ and ’ datetime ’ but the sql value store like this " 0000-00-00 00:00:00 " that’s why I use bigint()
I don’t know what is wrong with my code, does any one know ??