Re: Date formatting

From: Date: Fri, 06 Apr 2001 16:14:12 +0000
Subject: Re: Date formatting
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47459@lists.php.net to get a copy of this message
You need a UNIX timestamp for the second argument in date() - thus you need to first convert your $even into a timestamp (number of seconds past 1970). <? $event = '2001-03-15 24:03:34'; list($date,$time) = explode(' ',$event); list($year,$month,$day) = explode('-',$date); list($hour,$min,$sec) = explode(':',$time); $foo = mktime($hour,$min,$sec,$month,$day,$year)."\n"; echo date("D j M",$foo); ?> That would work ... --Joe On Fri, Apr 06, 2001 at 01:13:59PM +0100, Matt Davis wrote: > Hi I am trying to format a date extracted from my DB. I have run my query > and then have used the following to get my row data > > while ($row = mysql_fetch_array($sql_result)) { > $title = $row["message_title"]; > $message = $row["message"]; > $event = $row["date_of_event"]; > > $shortevent = date ("D j M", $event); > > I am trying to take $event and make it diplay like this "FRI 06 APR" using > the date function. Although $event outputs like this "2001-04-06 00:00:00" > $shortevent outputs "Thu 1 Jan" which is unix epoch date. > > Does anybody know what I am doiing wrong its probably something really > simple but I cant see what. > > Matt. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net /******************************************************************************\ * Joe Stump - PHP/SQL/HTML Developer * * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net * * "Better to double your money on mediocrity than lose it all on a dream." * \******************************************************************************/

« previous php.general (#47459) next »