Web Hosting Talk







View Full Version : Date Problem


imran7706
09-23-2006, 09:11 AM
Hello all
I am using this code to insert the current date in My SQL but I am not getting the correct result Hope my friends would help me here
$A = getdate();
$Today = mktime(0,0,0,$A['mon'], $A['mday']+15, $A['year']);
Thanks in advance

Oshaka
09-23-2006, 10:29 AM
Hello all
I am using this code to insert the current date in My SQL but I am not getting the correct result Hope my friends would help me here
$A = getdate();
$Today = mktime(0,0,0,$A['mon'], $A['mday']+15, $A['year']);
Thanks in advance


Why dont you just use somthing like,

insert into table(date) values(NOW())


That will insert the current date, if the structure of that column is set to DATE

Wim Conradie
09-26-2006, 04:51 PM
If you are using the MySQL DateTime variable type then in PHP you would use the following format

return gmdate("Y-m-d H:i:s", time() + 3600*$gmt);

for comparing, inserting, etc

An example date format will look like this: 2006-02-02 23:23:27

The $gmt is your time zone. (You can also add or subtract time this way)

imran7706
09-26-2006, 05:35 PM
Thanks it worked thanks again

superprogram
09-27-2006, 02:01 AM
Why dont you just use somthing like,

insert into table(date) values(NOW())


That will insert the current date, if the structure of that column is set to DATE

This command will insert the time from the MySQL server. What he wanted is to insert the time from the server where php is running