Page 1 of 1

get datetime filed to mysql db

Posted: Tue Sep 02, 2003 8:28 am
by yaron
Hi all,
I need to store the directory date (modify date) to mysql db.
I have a datetime field and here is the code I wrote:

$dDate=date("Y m d H i s", filemtime("$path"));
$insSql="INSERTINTO table (path,mdate) VALUES ('$path','$dDate')";
mysql_query($insSql);

the path is stored correctly but the date reamins empty and appear in the db.
0000-00-00 00:00:00
How can I correct it?
Thanks

Posted: Tue Sep 02, 2003 8:29 am
by yaron
no need....
Got it :-)

Posted: Tue Sep 02, 2003 9:02 am
by twigletmac
It could help others later if you post the solution you found...

Mac

Posted: Tue Sep 02, 2003 4:37 pm
by m3rajk
i think his issue was that the datetime field expects yyyy-mm-dd hh:mm:ss and if you don't have it like tht it's not correct so it goes to the default since your supplied value is invalid

Posted: Wed Sep 03, 2003 5:01 am
by twigletmac
That's what I thought, but I like to see people posting their solutions.

Mac

Posted: Wed Sep 03, 2003 9:10 am
by yaron
sorry guys
solution:
$dDate=date("Y-m-d H:i:s", filemtime("$path"));
simple as that...
:)