Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2003
    Posts
    137

    Unanswered: URGENT PLZ: Problem in date field.

    can you please help me with this...

    I am reading from the database using this code:

    $billing_sql = "SELECT billing.billing_id, billing.detail, billing.start_date_time, billing.amount FROM customers INNER JOIN (accounts INNER JOIN billing ON accounts.account_id = billing.account_id) ON customers.customer_id = accounts.customer_id WHERE customers.customer_id = '".$_SESSION['customer_id']."' AND billing.entry_type IN(1,2,5,6,7,8) ORDER BY start_date_time desc LIMIT 10";
    $billing_result = pg_exec($pg_connection, $billing_sql);
    $billing_date_time = pg_result($billing_result, $i, 2);


    but the date is stored in GMT and my local date is GMT+3

  2. #2
    Join Date
    Aug 2006
    Location
    San Francisco, CA
    Posts
    136
    I am not sure of the exact syntax but you should be able to just add 3 to the time. If I recall correctly you can add to the timestamp in the sql query. Not 100% sure on this but its worth a shot. And if it doesn't work, then you should see if you can change the timezone on the db. There should be some good threads around about db timezones and how to manipulate them
    Hope this helps
    Good luck

  3. #3
    Join Date
    Apr 2003
    Posts
    137
    I am not getting the correct +3 date when adding 3 to teh timestamp because it's for date and time as well and i just need to add +3 on the date

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what database is this? and what is the exact datatype of the start_date_time column?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Apr 2003
    Posts
    137
    database is PostgreSQL

    I don't have access to tha database today because I am off but if i can remember it's timestamp

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try
    Code:
    select start_date_time + interval '3 hours'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Apr 2003
    Posts
    137
    yes it worked

    thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •