Home > Software design >  Yii2 transform 'string' datetime to int(11) datetime
Yii2 transform 'string' datetime to int(11) datetime

Time:12-19

yii2 have a function that transform something like '1671380485' to 'December 21, 2022'.

Yii::$app->formatter->asDate('1671380485', 'medium');

Do yii2 have a function that will make Reverse effect? For example transform '2022-12-21' to int(11)?

CodePudding user response:

I believe PHP's strtotime() function is what you are looking for:

<?php
echo strtotime('2022-12-21'); // 1671606000
?>
  • Related