Retrieving Dates from Oracle DB

I am using Oracle DB and I am trying to extract data from my tables using PHP. One of the tables contains a date column, which behaves strangely to me.

When I open a table in my DB client (I use Navicat Lite), I see dates like "2007-11-29 10:15:42", but when I retrieve them using PHP and display the date, November 29-November 07 I use a simple SQL query and standard PHP functions (oci_parse, oci_execute, oci_fetch_array).

Why is the value from the database converted to this (useless) format? How can I get the date, just like it is stored in the database? Thanks for your advice!

+3
source share
1 answer

DATE Oracle - , . ( , , ), , , ( ). , PHP, , NLS_DATE_FORMAT.

:

  • NLS_DATE_FORMAT :

    ALTER SESSION SET NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
    
  • , , :

    SELECT to_char(my_date, 'yyyy-mm-dd hh24:mi:ss') ...
    

Update

ThinkJet PHP:

DATE , . Oracle, NLS_LANG ALTER SESSION SET NLS_DATE_FORMAT.

+7

Source: https://habr.com/ru/post/1758874/


All Articles