Re: Question About Date Function in PHP/MySQL

From: Date: Sun, 08 Feb 2004 16:28:17 +0000
Subject: Re: Question About Date Function in PHP/MySQL
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-177145@lists.php.net to get a copy of this message
John W. Holmes wrote:
Freedomware wrote:
When I view my data in phpMyAdmin, all I see in that column is NULL. When I preview it in a webpage, nothing displays at all. If I change it to NOT NULL, I see 0000-00-00 in every cell. Here's a row of text from the CSV file I imported into my MySQL table: "Alberta","Edmonton","1905-09-01",11,"NWT","AB","CAN" As you can see, the date is listed as "1905-09-01."
Well, that's the right format for a MySQL date; YYYY-MM-DD, so I don't know why it wouldn't load from your CSV file. Can you show the command that you use to import the file? If the fields are NULL (or 0000-00-00) in the database, then MySQL is not accepting your data (for the date field at least).
Wow, I think you solved it! I went to retrieve the link to the screen shots I put online when I was first trying to figure this stuff out - at http://geowebworks.geobop.org/test/php/ Towards the bottom of the page (#6) is a screen shot of something I was oblivious to this time around - Date and Time Formats. (I'm using a trial version of EMS MySQL Manager.) I'll bet that's my problem, though I'm still a bit confused. EMS lists the following: Short Date: M/d/yyyy Long Date: dddd, MMMM dd, yyyy Day followed by month, followed by another day, then year??? I thought it was supposed to be year first, followed by month and day, as in the example from CSV table - 1905-09-01. Should I change Long Date so that it reads YYYY-MM-DD, or something like that? Or maybe I can figure out how to do it in phpMyAdmin. I downloaded EMS phpMySQL because I couldn't create error-free tables with phpMyAdmin, but maybe I can use it to tweak my tables. Thanks for the tip!

« previous php.general (#177145) next »