Skip site navigation (1) Skip section navigation (2)

Re: Best way to convert PG's TIMESTAMPTZ to PHP DATE?

From: Michael Hanna <zen(at)hwcn(dot)org>
To: "David Busby" <busby(at)pnts(dot)com>
Cc: <pgsql-php(at)postgresql(dot)org>
Subject: Re: Best way to convert PG's TIMESTAMPTZ to PHP DATE?
Date: 2003-07-01 09:59:13
Message-ID: AB0C1A90-ABAA-11D7-A8B3-00039308EB2C@hwcn.org (view raw or whole thread)
Thread:
Lists: pgsql-php
Not sure why this results in nothing:

$query2 = "SELECT to_char(posted, 'Day, DD  HH12:MI:SS') FROM 
healthnotes";

Also, there are multiple postings per day, how do I SELECT only one? 
DISTINCT? Not sure how to do this..

Finally, if I ever get the output, would nested for-loops properly 
output the information such that for each date printed, it will print 
the multiple items on that day?

Michael

On Monday, June 30, 2003, at 09:42  PM, David Busby wrote:

> Hmmm,
>     Sometimes that happens to me too, I cannot seem to isolate what 
> causes
> it however.  When I get that I use the PG to_char function in my 
> statement
> to convert the value to something I can use in PHP.  I wish I could 
> provide
> more information about why this is hit and miss.
>
> /B
>
>
> ----- Original Message -----
> From: "Michael Hanna" <zen(at)hwcn(dot)org>
> To: "David Busby" <busby(at)pnts(dot)com>
> Cc: <pgsql-php(at)postgresql(dot)org>
> Sent: Monday, June 30, 2003 18:19
> Subject: Re: [PHP] Best way to convert PG's TIMESTAMPTZ to PHP DATE?
>
>
> for some reason I get:
>
> Wed, 31 Dec 1969 18:59:59 -0500
>
> as output on any entry.
>
> -----
>
> $rows = pg_num_rows($result);
>
> // if records present
> if ($rows > 0)
> {
>          // iterate through resultset
>          for ($i=0; $i<$rows; $i++)
>          {
>                  $row = pg_fetch_object($result, $i);
> $conv_date = date('r',strtotime($row->posted));
>          ?>
>                  <li><font size="-1"><b><? echo $conv_date; 
> ?></b></font>
>                  <br>
>
>                  <font size="-1"><? echo $row->notes; ?></font>
>                  <p>
>          <?
>          }
> }
>
> On Monday, June 30, 2003, at 04:06  PM, David Busby wrote:
>
>> Both of these work OK for me
>>
>> date('r',strtotime($record->date_field));
>>
>
>
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>


In response to

pgsql-php by date

Next:From: Bruno Wolff IIIDate: 2003-07-01 13:46:57
Subject: Re: PHP form Creates Blank DB entries
Previous:From: philip johnsonDate: 2003-07-01 08:06:37
Subject: Re: PHP form Creates Blank DB entries

Privacy Policy | About PostgreSQL
Copyright © 1996-2016 The PostgreSQL Global Development Group