我想显示用户在一个网站注册了多长时间。
示例:您在5天前创建了您的帐户。
如何做到这一点?我尝试使用user_info->user_registered
,但我只得到用户日期…
我到了。
我放注释是为了理解代码。
<?php
$today = time(); // Get the current date
$user_date = strtotime(get_userdata(get_current_user_id( ))->user_registered); // Get the user registration date
$diference = $today - $user_date; // Get the difference between today and the user registration date.
$diferencedays = floor($diference/(60*60*24)); // Transform the date to days.
echo $diferencedays; // Show the days.
?>
这是。