DEV Community

owais 7osha
owais 7osha

Posted on

How to solve Problem with date method in the Yii2?

0

Have timestamp for the task in the MySQL - 1654423473. https://babyapk.com/genshin-impact-mod-apk/ correctly transforming this timestamp into the GMT: Sunday, 5 June 2022 г., 10:04:33. That is date of task creation. Using this Yii2 method I outputting this data in the view - ` public function getWasOnSite() {

$timePeriod = strtotime('now') - strtotime($this->dt_add);
return \Yii::$app->formatter->asDuration($timePeriod);
Enter fullscreen mode Exit fullscreen mode

}
` And expecting some days, minutes, etc, but seeing this -1450 years, 11 months, 30 days, 17 hours, 3 minutes, 45 seconds ago

How to remake into the correct variant?

Top comments (0)