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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


/******************************************************************************\
 *                    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."   * 
\******************************************************************************/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to