PHP Help Needed...

Discussion in 'PHP' started by MakeThatDollar, Jun 15, 2008.

  1. #1
    How can I get the value from Date 2 minus Date 1?

    For example, if Date 1 = 08/19/2007 and Date 2 = 08/19/2009, I want the value to be equal to 2, for 2 years.

    $domain['date1'] = date('m/d/Y', $domain['date1']);
    $domain['date2'] = date('m/d/Y', $domain['date2']);
    $age = $domain['date2'] - $domain['date1'];

    Here's what I had, but displaying $age shows 0 no matter what.
     
    MakeThatDollar, Jun 15, 2008 IP
  2. X.Homer.X

    X.Homer.X Peon

    Messages:
    290
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    well, your trying to subtract the number 08/19/2007 that is not a number (slashes)

    you can get just the year, and subtract them, or you could make it one whole number. Also date goes by 30-31 days, while actual numbers go by base 10.

    if you were to do 892007 - 8192007 it would be 1 for one year, but if there were 5 days added onto that it would be 5000001,

    see your problem here?
     
    X.Homer.X, Jun 15, 2008 IP
  3. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #3
    Yes, thanks for the help. I got it working now.
     
    MakeThatDollar, Jun 15, 2008 IP