How to get Registered User Time Period in days in WordPress ?

Posted By: KP On June 26, 2010 Under Other, Programming Categories


Below code is useful to get how long the user is registered with your blog/website based on wordpress. The PHP code will give output time in days. You can convert that to month easily.

We need to convert timestamp stored by wordpress in MySQL as datetime format.

<?php

date_default_timezone_set('UTC'); //This must be same as your wordpress timezone

global $wpdb, $user_ID;
if(is_user_logged_in())
{
$userid=intval($user_ID);

$result = mysql_query(“SELECT ID,user_registered FROM wp_users WHERE ID=’$userid'”);
while($row = mysql_fetch_array($result))
{

$dd1=date(‘d M Y’,strtotime($row[‘user_registered’]));
$days = floor((time() – strtotime($dd1))/86400);

echo “User is registered since”.$days.” Days”;

}

?>

After getting days you can use it as a numerical value. Variable days will have final output.



Share with Friends ( Sharing is Caring! )


Subscribe For E-mail Notification Of Article Updates

Enter your email address:

NOTICE:
DO NOT FORGET TO CLICK ON THE VERIFICATION LINK AFTER SUBSCRIBING,THE VERIFICATION MAIL WILL BE SENT TO YOU FROM "FeedBurner Email Subscriptions".
( What is this? Why I need to do this?)

Related Posts

Post a Comment

OR