Re: convert date in german format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Ruprecht Helms" <rhelms@xxxxxxx>
> 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...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux