我想说明用户在网站上注册了多长时间。
示例:您创建了帐户 5天前。
怎么做?
我尝试使用user_info->user_registered
,但我只获得了用户日期......
答案 0 :(得分:1)
我来了。
我发表评论以理解代码。
<?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.
?>
是的。