tags:

views:

64

answers:

1

Hi Folks,

iam confused. Iam trying to read an Value from an oracle table, format: timestamp(6).

In my PHP Scripts im setting the Dateformat with:

$db->query('ALTER SESSION SET NLS_DATE_FORMAT = "DD-MM-RR"');

On 2 Machines im recieving this string as value (wich is correct for me): ["TIME_INSERT"] => string(24) "05.10.07 14:20:05,000000"

On one linux machines where the same script is running, it returns: ["TIME_INSERT"] => string(28) "05-OCT-07 02.20.05.000000 PM"

any ideas how to change this ?

+4  A: 

Hi ArneRie,

you should set the session parameter NLS_TIMESTAMP_FORMAT or NLS_TIMESTAMP_TZ_FORMAT to display timestamp data as you want:

SQL> select systimestamp from dual;

SYSTIMESTAMP
----------------------------------------------------
12/10/09 12:52:41,462532 +02:00

SQL> ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT = 'dd.mm.rr hh24:mi:ss,ff5';

Session altered

SQL> select systimestamp from dual;

SYSTIMESTAMP
--------------------------------------------------------------------------------
12.10.09 12:56:36,14023
Vincent Malgrat
I generally use a TO_CHAR() in the SQL or bind to a JDBC data type. Seems better than setting a session parameter.
WW
...and use TO_DATE(...) the other way to insert values in the format of your choice.
awe
@WW and awe: I agree, I always advocate the use of explicit date conversion.
Vincent Malgrat
sorry still the same result after setting the timestamp format (;
ArneRie
works now :) used : NLS_TIMESTAMP_FORMAT , not TZ_FORMAT!
ArneRie