Yii Framework Forum: Yii2 Insert mysql data type time - Yii Framework Forum

Jump to content

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

Yii2 Insert mysql data type time

#1 User is offline   Arockia Johnson SR 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 191
  • Joined: 25-June 13
  • Location:Singapore

Posted 30 November 2017 - 10:19 AM

Hi Guys,

I want to insert into mysql table data type time through model. Really I don't have any idea about expressions!.

If I directly try at phpmyadmin I can insert "10:00:00" but via Yii2 model I can't do it!
மகிழ்ச்சியாக குறியிடுங்கள்!..... Happy Coding!.....


Thanks & Regards,
ஜான்சன் ( Arockia Johnson SR )
www.arojohnson.tk

Hit (+) button If my replies really helped you!
0

#2 User is offline   Arockia Johnson SR 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 191
  • Joined: 25-June 13
  • Location:Singapore

Posted 01 December 2017 - 01:33 AM

Hi Guys,

Any luck?
மகிழ்ச்சியாக குறியிடுங்கள்!..... Happy Coding!.....


Thanks & Regards,
ஜான்சன் ( Arockia Johnson SR )
www.arojohnson.tk

Hit (+) button If my replies really helped you!
0

#3 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 563
  • Joined: 08-October 12
  • Location:Austria

Posted 01 December 2017 - 02:10 AM

Hi Johnson,

Have you refer below two links

http://webtips.kraje...t-formats-yii2/

http://www.yiiframew...mpbehavior.html
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/
http://www.yiiframew...uallistboxyii1/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#4 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,493
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 03 December 2017 - 04:03 AM

yii should not interfere with your database schema unless you tell it to, can you paste your code here and your table schema ?
0

#5 User is offline   Arockia Johnson SR 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 191
  • Joined: 25-June 13
  • Location:Singapore

Posted 03 December 2017 - 09:21 PM

Hi Guys,

Really thanks for your replies!. I tried to use the formatter but forgot to prepend "php:". After looking deeply at the links posted by Mr. Chandran I found it!. :(

I changed to the following then worked fine for me.

Yii::$app->formatter->asDate($dateStr,"php:H:i:s"); // Example $dateStr -> "09:15:00" 



The table is like below


CREATE TABLE `timetable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `school_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `from_time` time NOT NULL, //This is the one field
  `to_time` time NOT NULL //This the one field
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




Really thanks once again!
மகிழ்ச்சியாக குறியிடுங்கள்!..... Happy Coding!.....


Thanks & Regards,
ஜான்சன் ( Arockia Johnson SR )
www.arojohnson.tk

Hit (+) button If my replies really helped you!
1

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