Reply to RE: [PHP] Varchar "date" to real date?

Your name:

Reply:


Posted by Jim Moseby on 12/27/05 16:35

>
> Hello,
>
> This is propably a more of a MySQL question but here we go anyway...
>
> I have a DB that has dates stored in a table. The date field
> type is Varchar
> (don't ask why... :( The dates are stored using european date format
> DD.MM.YYYY. I need somehow convert the dates to the format MySQL uses
> (YYYY-MM-DD) and re-store them to a table which has a real
> date column for
> them.
>
> I think I need some help/ideas with this...
>
> If I can get this done how can I still display the dates in
> european format
> at my web page? Do I have to break the date to pieces and some how
> re-arrange it to the DD.MM.YYYY format or is the some clever
> function for
> this that can automatically do this?
>
> Thanks
> -Will
>


function eurodate_to_mysqldate($date){
$parts=explode('.',$date);
$day=$parts[0];
$month=$parts[1];
$year=$parts[2];
return($year.'-'.$month.'-'.$day);
}

This (untested) function will take the varchar date you described and
convert it to a date that mysql will like.

JM

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация