Yii Framework Forum: How To Use To_Date() For Oracle - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Use To_Date() For Oracle Rate Topic: -----

#1 User is offline   sandeep kaushik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 22-August 13

Posted 19 November 2013 - 01:27 AM

Friends, I am unable to save date and time in oracle. If I take date as datatype it cant save hours and min. and if i take timestamp. it oracle cant save hours more than 12 whereas it it takes hours upto 12. friends please suggest how to go about?
0

#2 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 19 November 2013 - 02:42 AM

I don't know if that's going to resolve your issue, but I found out that I need to set up the default date/time and numbers format after connecting to Oracle by adding the following to the 'db' component configuration:
'initSQLs' => array(
 "ALTER SESSION SET NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'",
 "ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '. '",
),


It's a shame you can't disable the thousand separator, because that breaks some number processing.
Don't be a dick.
0

#3 User is offline   sandeep kaushik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 22-August 13

Posted 20 November 2013 - 03:20 AM

thank u bro. But I solved it by changing the date format in beforeSave and converting to 12 hour format and and reversed it afterFind. thanks
0

#4 User is offline   Raciel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 04-July 17

Posted 05 July 2017 - 03:26 PM

View Postsandeep kaushik, on 20 November 2013 - 03:20 AM, said:

thank u bro. But I solved it by changing the date format in beforeSave and converting to 12 hour format and and reversed it afterFind. thanks

Hi:
I´m usign Yii2 with oracle db, and in the table, I have a field type DATE that contains the date and time of the INSERT RECORD.

The problem is, when I try to show it in the gridview or detailview widget...
I tried to doit with the use of 'yii\i18n\Formatter' in the main configuration, like this

'formatter' => [
'class' => 'yii\i18n\Formatter',
'dateFormat' => 'php:d/m/Y',
'datetimeFormat' => 'php:d/m/Y H:i:s',
'timeFormat' => 'php:H:i:s',
'nullDisplay' => '-',
],



and in the index view like this

<?= GridView::widget([
(...)
columns => [
'dateField:datetime',
(...)
],
])?>


but all I get in the view is "25/06/2017 00:00:00", I DON'T KNOW WHY ???
when i do the "select to_char(dateField, 'DD/MM/YYYY HH24:MI:SS') from temp" i get '25/06/2017 22:50:20' and this is what i need to get.

how can i do it rigth.
i need some help
thanks.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users