Re: PHP date() and MySQL timestamp problem

From: Date: Sat, 11 Nov 2000 04:09:59 +0000
Subject: Re: PHP date() and MySQL timestamp problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24754@lists.php.net to get a copy of this message
On 10-Nov-00 Ignacio Vazquez-Abrams wrote: > On Fri, 10 Nov 2000, Tom Harris wrote: > <snip> >> >> I have a timestamp column in MySQL that I want to format into a normal >> date. >> The code I used was >> >> 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. >> <nother snip> > > 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 save a step : "select UNIX_TIMESTAMP(modified) as mod from ..." date('d M Y', $row->mod) save 2 steps : select DATE_FORMAT('%d %M %Y",modified) as fmtmod from ..." echo $row->fmtmod Regards, -- Don Read dread@texas.net There are old sailors, and there are foolish sailors; but damn few old foolish sailors. ---------------------------------------------

« previous php.general (#24754) next »