简体   繁体   English

如何在Wordpress中获得用户帐户有效期

[英]How to get the user account duration in the Wordpress

I would like to show how long the users are registered in a website. 我想显示用户在网站中注册的时间。

Example: You created your account 5 days ago . 示例:您5天前创建了帐户。

How to do this? 这个怎么做? I tried using user_info->user_registered , but i only got the user date... 我尝试使用user_info->user_registered ,但是我只有用户日期...

I got here. 我去那儿。

I put comments to understand the code. 我添加注释以了解代码。

<?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.
?>

Is this. 这是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM