RE: [PHP] PHP date() and MySQL timestamp problem
| From: | Layne Weathers | Date: | Fri, 10 Nov 2000 22:37:48 +0000 |
| Subject: | RE: [PHP] PHP date() and MySQL timestamp problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24735@lists.php.net to get a copy of this message | ||
> > date ("d M Y", $modified)
> > $modified is the value from the timestamp column. However
> it give a very
> > wrong date. Anything I've modified today comes out as 18 Jan 2038.
> You're doung it all wrong. The TIMESTAMP MySQL datatype has the format
> "YmdHis" format (PHP date() format). You have to use substr()
> to break it
> up first.
Or you can use the date functions built into MySQL to do the trick as well.
If you don't mind getting a leading zero use "select date_format($column,
'%d %M %Y') from $table". Or, if you want to pull from PHP's larger
formatting options, "select unix_timestamp($column) as $column from $table"
then run date() on the result.
Layne Weathers
Ifworld, Inc.
layne@ifworld.com