how to save datetime to integer

view:

<?= $form->field($model, ‘fecha_ingreso’)->widget(DateTimePicker::classname(), [

'options' =&gt; ['placeholder' =&gt; 'Seleccione la fecha de ingreso'],


'pluginOptions' =&gt; [


    'autoclose' =&gt; true,


    'format' =&gt; 'yyyy/dd/mm hh:ii:ss',


]


]);?&gt;

//////////

fecha_ingreso is integer

Use php function strtotime() setting the property like this

$model->fecha_ingreso = strtotime($model->fecha_ingreso).

Not tested but should work.

i had change the widget because the datatime picker not have this opction to save:

‘saveFormat’ => ‘strtotime($model->fecha_ingreso)’,

or more easy… ‘saveFormat’ => ‘php:U’, thanks!