convert date to timestamp in yii2?

$date = Yii::$app->request->post('date');
$timestamp = strtotime($date);
var_dump($timestamp );


PHP Warning – yii\base\ErrorException strtotime() expects parameter 1 to be string, array given

1 answer

  • answered 2019-11-08 16:39 scaisEdge

    you should check you post for an array in $_POST('date')

    in this case you could access at the value providing an index

    $timestamp = strtotime($date[0]);