hello everyone
i built a function to be able to determine when a user last logged into the site. The function works perfectly. However, when it comes to the last part of the function an error report is produced .
its best if i show u the function.
function logindate( $datelogin= NULL ) {
//the fuction takes a timestamp of the date that a user last logged in, this was // taken from the database.
// i now get a unix timestamp of the current date and time .
$currentdate = time ();
//i simple substract the date of the users last login from the current date
//i then use an if test to determine whether the person logged in within the last //two days
//if not i then convert the unixtime stamp back to a readable date using
//the DATE function.
$logindate = ( $currentdate- $datelogin );
if (( "$logindate" >= '00001') && ( "$logindate" <= '86400') ) {
echo' Today';
}
elseif (( "$logindate" >= '86401') && ( "$logindate" <= '172800') )
{
echo' Yesterday ';
}
else
{
$date = date("d M Y " , $datelogin );
return $date ;
}
}
//i am calling the function and giving it a UNIX timestamp: this date would normally come from the database
logindate('500835843' ) ;
the problem is that when i try to convert the date back to a human readable date it produces the following error report
A non well formed numeric value encountered
the error report relates to the $datelogin variable that i placed within the
$date = date("d M Y " , $datelogin );
when i however substituted the '$datelogin variable' for an actual number it work perfectly , and no error report was produced. So the problem must be in the way i have used the variable.
thank you everyone for your kind help
warm regards
Andreea