Users Birthday

Christiaan Pot Posted in Professional Services 9 years ago

Hi does anyone know what the problem is met this code .

there is no result except when I give 2015 as the year of birth .

He also calculated no age

foreach ($users as $user) {
                $user  = ossn_user_by_guid($user->guid);
                $today = date('d/m/Y');
                $user->birthdate;
                $interval = date_diff($today, $user->birthdate);

                if ($today == $user->birthdate) {
                                echo 'today is ' . $user->username . 'birthday (' . $interval . ')';
                } else {
                                echo "";
                }
}
Replies
in Sathish kumar Replied 9 years ago

@christiaan pot can you send your plugin as file or host it in github so that we can check with that

Indonesian Arsalan Shah Replied 9 years ago

I'll create a birthdate component , which shows brithdays of friends, in few days.

Byelorussian Christiaan Pot Replied 9 years ago

I dont understand

like this?

<?php 
$user->username;
$user->birthdate;
$date1=datecreate($user->birthdate);
$date2=datecreate(date('Y/m/d'));
vardump($date1);
$diff=datediff($date1,$date2);

if ( $date1 == $date2)
{
echo 'today is ' .$user->username. ' birthday (' .$diff->format("%R%a"). ')';
}
else
{
echo '';
}
?>
in Sathish kumar Replied 9 years ago
<?php
$date1=date_create("1989/12/26");
$date2=date_create(date('Y/m/d'));
var_dump($date1);
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");
?>
in Sathish kumar Replied 9 years ago

Your not passing the value correctly
in

 date_diff
 you have to pass with time also  verify this .

http://php.net/manual/en/datetime.diff.php

or pass like this

<?php
$date1=date_create("1989/12/26");
$date2=date_create(date('Y/m/d'));
var_dump($date1);
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");
?>
Byelorussian Christiaan Pot Replied 9 years ago

I try to show the birthdays

with the ages behind it.

but he shows them only when the year is equal to now

Indonesian Arsalan Shah Replied 9 years ago

What are you trying to achieve ?