pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lynna Landstreet <lynna@gallery44.org>
To: pgsql-php@postgresql.org
Subject: Getting the year from a date column
Date: Wed, 23 Jul 2003 17:49:54 -0400
Message-ID: <BB447B42.790%lynna@gallery44.org> (raw)

I'm having a bit of trouble with one part of the PHP front end of the art
gallery database I'm working on - specifically, extracting the year from the
start date of an exhibition. I'm trying to print a list of exhibitions on
the artist info pages, with the name, gallery space and year for each one,
and everything's working except the year part.

Here's what I have. First, near the beginning of the PHP portion of the
page:

    $exh_query = "SELECT exhibition_name, start_date
        FROM exhibitions WHERE  exhibition_id = '$exhibition_id'";
    $exhibition_info = pg_exec($db, $exh_query);

Then further down, where I want the year to appear in the exhibition list:

    $date = getdate (pg_result($exhibition_info, 0, 'start_date'));
    $year = $date['year'];
    echo $year;

(The 0 for row is because the way the code is structured, $exhibition_info
only contains one row.) But I'm not sure if getdate() is the right function
to be using. It was the only function I could find in the PHP manual that
was capable of breaking out the individual components of a date (day, month,
year, etc.), but it seems to be ignoring the actual date in the query
results and returning '1969' for everything.

Any idea what I'm doing wrong? Is there a different function I should be
using instead for this? BTW, I'm using PHP 4.1 (and PostgreSQL 7.2), thus
the old-style pg function names (pg_result(), etc.).

Thanks,

Lynna
-- 
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org




view thread (3+ messages)  latest in thread

Message-ID: <BB447B42.790%lynna@gallery44.org>
Permalink:  ../BB447B42.790%25lynna@gallery44.org/
Also on:    postgresql.org/message-id/BB447B42.790%lynna@gallery44.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: lynna@gallery44.org
  Subject: Re: Getting the year from a date column
  In-Reply-To: <BB447B42.790%lynna@gallery44.org>
  References: <BB447B42.790%lynna@gallery44.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox