Доброе утро.
Можно получить таким образом разницу между датами.
Получаем разницу между датой регистрации пользователя и датой, когда он последний раз редактировал свой профиль.
SELECT `username`, DATEDIFF(FROM_UNIXTIME(`updated_at`), FROM_UNIXTIME(`created_at`)) AS `date_diff` FROM `user`
В результате получим следующее:Array
(
[0] => Array
(
[username] => admin
[date_diff] => 261
)
[1] => Array
(
[username] => Denis
[date_diff] => 73
)
[2] => Array
(
[username] => Vitaliy
[date_diff] => 80
)
[3] => Array
(
[username] => Elena
[date_diff] => 78
)
[4] => Array
(
[username] => Boris
[date_diff] => 0
)
[5] => Array
(
[username] => Daniel
[date_diff] => 0
)
[6] => Array
(
[username] => Vladimir
[date_diff] => 42
)
[7] => Array
(
[username] => Vasya
[date_diff] => 0
)
[8] => Array
(
[username] => Anton
[date_diff] => 0
)
[9] => Array
(
[username] => Nicolay
[date_diff] => 5
)
)
Или получим разницу между текущей датой и датой регистрации пользователя
SELECT `username`, DATEDIFF(CURDATE(), FROM_UNIXTIME(`created_at`)) AS `date_diff` FROM `user`
В результате получим следующее:Array
(
[0] => Array
(
[username] => admin
[date_diff] => 794
)
[1] => Array
(
[username] => Denis
[date_diff] => 616
)
[2] => Array
(
[username] => Vitaliy
[date_diff] => 515
)
[3] => Array
(
[username] => Elena
[date_diff] => 315
)
[4] => Array
(
[username] => Boris
[date_diff] => 215
)
[5] => Array
(
[username] => Daniel
[date_diff] => 200
)
[6] => Array
(
[username] => Vladimir
[date_diff] => 175
)
[7] => Array
(
[username] => Vasya
[date_diff] => 150
)
[8] => Array
(
[username] => Anton
[date_diff] => 149
)
[9] => Array
(
[username] => Nicolay
[date_diff] => 149
)
)