Thread: date difference

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    helo,
    i want to find out date difference.
    such as $a="2000-10-9"
    $b="2000-10-10"
    echo $c=$b-$a;
    $c will be 1.
    how can i make it
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    24
    Rep Power
    0
    Here's a very brief solution:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> $first = strtotime( "2000/10/25" );
    $second = strtotime( "2000/10/21" );

    $diff = abs(($second - $first) / 3600 / 24);

    echo "Difference in days: $diff";[/code]

    You were after strtotime() which converts a date string into an integer, then you can do math on them.

    Hope this helps,

    ------------------
    - weeder
  4. #3
  5. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Take a look at the following article:
    http://www.phpbuilder.com/columns/akent20000610.php3

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. database date selection problem
    By kidsleep in forum MySQL Help
    Replies: 0
    Last Post: January 31st, 2004, 10:50 AM
  2. Odd problem with a hash and foreach loop
    By quantumechanix in forum Perl Programming
    Replies: 7
    Last Post: December 15th, 2003, 05:06 PM
  3. date addition problem
    By strange1 in forum PHP Development
    Replies: 3
    Last Post: October 6th, 2003, 04:01 PM

IMN logo majestic logo threadwatch logo seochat tools logo