All,
Im guessing this is going to be easy for any one to answer bc im such a fucking noob but here goes. I have mysql fields set to DATETIME and i just want to pull out that data and have it display in my form. And i would also like to know how to insert a date into a mysql DATETIME field if you guys would be so kind as to assist. I really really would appreciate any help. Thanks guys

Member Avatar for diafol

Have you checked out mysql_query in the php.net manual?

ALso, I have answered this question (or similar) about 3 times recently on this forum - have you tried searching the forum for the answer?

well thats the thing guys, im not really sure what i should look for. I googled every possible string i could think of that made sense but i couldnt find (or make sense of) my answer. I will continue to search though, thanks anyway fellaz. I appreciate your time

OK to format the date and time as 13/01/2012 08:15 AM using 24 hour format (for example), $row would be the variable you are storing your result from the database in:

$datetime = date('d/m/Y H:i A', strtotime($row['datetime']));
echo $datetime;

If you only need the date then take out H:i:A
To change it back to insert into the database

$datetimefordatabase = strtotime($_POST['date_time']);

Even though php.net is a nightmare to use, their list of date and time formats is useful and can be found here

Member Avatar for diafol

Even though php.net is a nightmare to use...

You can't be serious?!

Yes I am, it is awful if you are new to PHP. It doesn't explain things properly for those who are learning.

I couldnt agree more pixie!! I hate that effing website, its descriptions are extremely confusing to a noob like me and i thought i was making really good progress learning this stuff on my on lol but seriously dude, what you wrote out for me makes PERFECT sense so i cant be that big of a noob (ok, dont comment to that). Thanks a million man, you are truly helpful.

Glad I could help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.