RE: [PHP-DB] Time'n Date trouble - format pain
| From: | John W. Holmes | Date: | Mon, 26 May 2003 16:17:48 +0000 |
| Subject: | RE: [PHP-DB] Time'n Date trouble - format pain | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28048@lists.php.net to get a copy of this message | ||
> As my nightmare comes true I have to input CSV files into a MySQL DB.
>
> The Date(time) format can differ in 3 different ways:
> - - MM/DD/YYYY e.g. 06/25/2002
> - - DD/MM/YYYY e.g. 17/03/2003
You're pretty screwed on those two. If you have 03/04/2003, is it MM/DD
or DD/MM ??? Can't tell...
> ... AND ...
> - - "Sat, 19 Apr 2003 12:57:23 +0200" :(((
> Do you have some hint for me how I can avoid a pain of explode()s and
> endless parsing?
Strtotime() will give you a unix timestamp for the second and third
formats, I think. You can then convert that into a MySQL timestamp using
date.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/