Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 811269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:01:06+00:00 2026-05-15T01:01:06+00:00

I have two users in my database whose birth date is set to: 1985-01-26

  • 0

I have two users in my database whose birth date is set to:

1985-01-26

And then I have function which when provided the users’ date, tells how many days are left in the birthday. Here is the function:

function retage($iy,$im,$id)
{
    if(!empty($iy)>0 && intval($im)>0 && intval($id)>0)
    {
        $tdo=$iy.'-'.$im.'-'.$id;
         $tdc=date('Y').'-'.$im.'-'.$id;
        /*echo "<br/>";*/
         $cd=date('Y-n-j');
        /*echo "<br/>";*/
        if(strtotime($tdc)>strtotime($cd))//coming
        {
            $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365));
            $td=floor((strtotime($tdc)-strtotime($cd))/(24*3600));
            if($td==1)
            {
                $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' day to go';
            }
            else
            {
                $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' days to go';
            }
            $ty='<font color="#C7C5C5">is turning '.$ty.' on <br>'.date('M jS Y',strtotime($tdc)).'</font>';
            //return 'is turning '.$ty.' on '.$tdc;
        }
        elseif(strtotime($tdc)<strtotime($cd))//past
        {
            $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365));
            if($ty>0)
            {
                //$td='gone '.floor((strtotime($cd)-strtotime($tdc))/(24*3600)).' days ago';

                $ndays=floor((strtotime($cd)-strtotime($tdc))/(24*3600));

                if($ndays==1)
                    $td=' gone '.round((strtotime($cd)-strtotime($tdc))/(24*3600)).' day ago';
                else
                    $td=' gone '.round((strtotime($cd)-strtotime($tdc))/(24*3600)).' days ago'; 

                $ty='<font color="#C7C5C5">had turned '.$ty.' on <br>'.date('M jS Y',strtotime($tdc)).'</font>';
                //return 'had turned '.$ty.' on '.$tdc;
            }
            else
            {
                $tdc=(date('Y')+1).'-'.$im.'-'.$id;
                $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365));
                //$td=floor((strtotime($tdc)-strtotime($cd))/(24*3600)).' days to go';
                $td=floor((strtotime($tdc)-strtotime($cd))/(24*3600));
                if($td==1)
                {
                    $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' day to go';
                }
                else
                {
                    $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' days to go';
                }

                $ty='<font color="#C7C5C5">is turning '.$ty.' on <br>'.date('M jS Y',strtotime($tdc)).'</font>';
                //return 'is turning '.$ty.' on '.$tdc;
            }
        }
        else//today
        {
            $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365));
            if($ty>0)
            {
                $td='today';
                $ty='<font color="#C7C5C5">has turned <br>'.$ty.' on today </font>';
                //return 'has turned '.$ty.' on today';
            }
            else
            {
                $ty='<font color="#C7C5C5">today</font>';$td='';
                //return '';
            }
        }
    }
    else
    {
        $ty='';$td='';
        //return '';
    }
    $ta[0]=$ty;
    $ta[1]=$td  ;
    return $ta;
}

I use below code to show the days remaining:

while($rs=mysql_fetch_array($result))
{
if (isset($rs['byear'],$rs['bmonth'],$rs['bdate']))
  {
    $tmptxt = retage($rs['byear'],$rs['bmonth'],$rs['bdate']);
    echo $tmptxt[1];
  }
}

The strange thing is that for one user, the days remaining is shown correctly eg:

gone 120 days ago

And for other user having same birth date, this is shown:

Jan 1st 1970  -14755 days to go

Strange:

When I use the same function outside of the loop and test with date 1985-01-26, the correct result is shown.

What could be wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:01:07+00:00Added an answer on May 15, 2026 at 1:01 am

    Jan 1st 1970 is what you get with a unix timestamp of 0 / invalid date. Are you sure the data in the database is accurate?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple database with two tables. Users and Configurations. A user has
I have a table, users, in an Oracle 9.2.0.6 database. Two of the fields
I have two users Bob and Alice in Oracle, both created by running the
Say that I have two models- Users and Accounts. Each account can have at
If two users edit the same wiki topic, what methods have been used in
Let's say you have two tables, Users and UserRoles. Here's how the two tables
I have a .NET webforms front end that allows admin users to upload two
I'm using LINQ to SQL and C#. I have two LINQ classes: User and
I have two models indexed for searching (User and Item). I'm trying to do
Suppose you have two models, User and City, joined by a third model CityPermission:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.