PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
yaron
Forum Contributor
Posts: 157 Joined: Fri Aug 22, 2003 8:40 am
Post
by yaron » Tue Sep 02, 2003 8:28 am
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
yaron
Forum Contributor
Posts: 157 Joined: Fri Aug 22, 2003 8:40 am
Post
by yaron » Tue Sep 02, 2003 8:29 am
no need....
Got it
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Sep 02, 2003 9:02 am
It could help others later if you post the solution you found...
Mac
m3rajk
DevNet Resident
Posts: 1191 Joined: Mon Jun 02, 2003 3:37 pm
Post
by m3rajk » Tue Sep 02, 2003 4:37 pm
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
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Sep 03, 2003 5:01 am
That's what I thought, but I like to see people posting their solutions.
Mac
yaron
Forum Contributor
Posts: 157 Joined: Fri Aug 22, 2003 8:40 am
Post
by yaron » Wed Sep 03, 2003 9:10 am
sorry guys
solution:
$dDate=date("Y-m-d H:i:s", filemtime("$path"));
simple as that...