Re: convert date in german format

From: Date: Wed, 26 Nov 2003 16:10:19 +0000
Subject: Re: convert date in german format
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-31773@lists.php.net to get a copy of this message
From: "Ruprecht Helms" <rhelms@mayn.de> > how can I convert a date stored in a mysql-database for output > in the german format (dd.mm.yy). > > I tried date ("d.m.y",$row->from); > > but I still get the english-format stored in the database. > The databasefield is type date. That's because date() wants a Unix timestamp. MySQL has it's own format. You have two options. Option 1 is to use DATE_FORMAT() in your query to retrieve the date already formated. DATE_FORMAT() works similar to the PHP date() function. Look it up in Chapter 6 of the MySQL Manual. Option 2 is to use UNIX_TIMESTAMP() in your query to retrieve the MySQL date formatted as a Unix timestamp. You can then pass this value to the PHP date() function and format it like you have above. ---John Holmes...

« previous php.db (#31773) next »