Yii Framework Forum: format date berubah sendiri - Yii Framework Forum

Jump to content

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

format date berubah sendiri Rate Topic: -----

#1 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 06 April 2011 - 02:10 AM

Gan, ane melakukan query dari database :

Class A
{
private xxx;


public function getContent()
{
$connection = Yii::app()->db;
$command = " query ";

$dataReader=$connection->createCommand($command)->query();
$rows=$dataReader->readAll();

return $rows;
}

}

terus di controller


public function actionView()
{
$model = new A;
$hasil = $model->getContent();

$this->render('index.php');
}


nah ketika ane print_r($hasil); di controller nya.

Kenapa data tanggal dari database berubah secara otomatis :

di database : 3/4/2011 11:30:00

tapi di $hasil muncul $hasil[0][EVENTDATE] => 04-MAR-11

ada yang tau kenapa gan?

makasih yah.
0

#2 User is offline   epi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 06-April 11

Posted 06 April 2011 - 02:34 AM

yang dimauin harusnya gimana gan ?
feeling ana sih karena dia ikut formatnya yii.

View Postcocobi, on 06 April 2011 - 02:10 AM, said:

Gan, ane melakukan query dari database :

Class A
{
private xxx;


public function getContent()
{
$connection = Yii::app()->db;
$command = " query ";

$dataReader=$connection->createCommand($command)->query();
$rows=$dataReader->readAll();

return $rows;
}

}

terus di controller


public function actionView()
{
$model = new A;
$hasil = $model->getContent();

$this->render('index.php');
}


nah ketika ane print_r($hasil); di controller nya.

Kenapa data tanggal dari database berubah secara otomatis :

di database : 3/4/2011 11:30:00

tapi di $hasil muncul $hasil[0][EVENTDATE] => 04-MAR-11

ada yang tau kenapa gan?

makasih yah.

0

#3 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 06 April 2011 - 03:10 AM

View Postepi, on 06 April 2011 - 02:34 AM, said:

yang dimauin harusnya gimana gan ?
feeling ana sih karena dia ikut formatnya yii.



yang ane inginkan data sama seperti aslinya gan.. thanks responya. :D
0

#4 User is offline   yuda 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 23-December 10

Posted 06 April 2011 - 05:31 AM

  • Coba cek data yang tersimpan di fieldnya bener ga formatnya
  • Tipe data field yang nyimpen tanggalnya datetime ga?
  • Coba dari querynya dibikin format datenya gan, misalnya kek gini
    SELECT DATE_FORMAT(fieldName, '%d %m %Y %H:%i:%s') AS tanggal


Yang querynya belom ane coba sih, heheheh...
0

#5 User is offline   -=YiieRz=- 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 177
  • Joined: 27-October 10
  • Location:Jakarta

Posted 06 April 2011 - 09:14 PM

View Postcocobi, on 06 April 2011 - 02:10 AM, said:

Gan, ane melakukan query dari database :

Class A
{
private xxx;


public function getContent()
{
$connection = Yii::app()->db;
$command = " query ";

$dataReader=$connection->createCommand($command)->query();
$rows=$dataReader->readAll();

return $rows;
}

}

terus di controller


public function actionView()
{
$model = new A;
$hasil = $model->getContent();

$this->render('index.php');
}


nah ketika ane print_r($hasil); di controller nya.

Kenapa data tanggal dari database berubah secara otomatis :

di database : 3/4/2011 11:30:00

tapi di $hasil muncul $hasil[0][EVENTDATE] => 04-MAR-11

ada yang tau kenapa gan?

makasih yah.


Agan taruh webappnya di server yah gan ? kalo betul jawabannya kemungkinan besar masalahnya ada di settingan timezonenya. coba cek di php.ini nya, atau set langsung dari webappnya agan.
untuk referensi timezone bisa di cek disini TimeZone Asia
belajar itu modal utama, tanpa percobaan itu tak akan berhasil. berdoa itu membuat kita percaya diri. YiieRz-SdgBlajar
www.yiiframework.com
0

#6 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 06 April 2011 - 09:51 PM

udah ane lakuin gan :

date.timezone = "Asia/Bangkok"

atau

date.timezone = "America/New_York"

terus ane restart apache... tapi hasilnya sama. :(
0

#7 User is offline   junxiong 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 541
  • Joined: 21-June 10

Posted 06 April 2011 - 10:53 PM

format mysql itu
month-day-year
karena agan input 3/4/2011
otomatis hasilnya yah: Maret, 4 2011
biasanya sih kalau input ane pake format ini

date("Y-m-j h:i:s");
“The most likely way for the world to be destroyed, most experts argue, is by accident. That’s where we come in; we’re computer professionals. We cause accidents.” - Nathaniel Borenstein

Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
0

#8 User is offline   -=YiieRz=- 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 177
  • Joined: 27-October 10
  • Location:Jakarta

Posted 07 April 2011 - 10:17 PM

View Postcocobi, on 06 April 2011 - 09:51 PM, said:

udah ane lakuin gan :

date.timezone = "Asia/Bangkok"

atau

date.timezone = "America/New_York"

terus ane restart apache... tapi hasilnya sama. :(


Asia/Jakarta gimana gan ? ... yg di comp client jakarta? bukan bangkok kan?
belajar itu modal utama, tanpa percobaan itu tak akan berhasil. berdoa itu membuat kita percaya diri. YiieRz-SdgBlajar
www.yiiframework.com
0

#9 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 10 April 2011 - 10:03 PM

View Post-=YiieRz=-, on 07 April 2011 - 10:17 PM, said:

Asia/Jakarta gimana gan ? ... yg di comp client jakarta? bukan bangkok kan?



sama gan. masih belum ketemu. kenapa bisa berubah. :(
0

#10 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 12 April 2011 - 08:11 PM

View Postjunxiong, on 06 April 2011 - 10:53 PM, said:

format mysql itu
month-day-year
karena agan input 3/4/2011
otomatis hasilnya yah: Maret, 4 2011
biasanya sih kalau input ane pake format ini

date("Y-m-j h:i:s");



ane ga input gan, hanya ambil data dari database, database yang ane gunakan adalah ORACLE.

nama kolom nya EVENTDATE nilainya : 3/4/2011 11:30:00

nah, pas pake query diambil, keluarannya 04-MAR-11

ane dah cek php.ini tapi tidak ada perubahan, ane gunakan search() dengan CDbCriteria, hasilnya sama.

Masta2, help me dunk... :D
0

#11 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 12 April 2011 - 09:16 PM

SOLVED : to_char(EVENTDATE, 'dd-mm-yyyy HH12:MI:SS') ;)
1

#12 User is offline   fastcrash 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 10-March 10
  • Location:South Jakarta

Posted 13 April 2011 - 01:06 AM

View Postcocobi, on 12 April 2011 - 09:16 PM, said:

SOLVED : to_char(EVENTDATE, 'dd-mm-yyyy HH12:MI:SS') ;)


he hee, jadi inget dulu pake ora harus masukin fungsi to_char, to_date di querynya.
ternyata TS nya pake ora :)
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