Results 1 to 6 of 6

Thread: [RESOLVED] PHP DateDiff()

  1. #1

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Resolved [RESOLVED] PHP DateDiff()

    please can anyone help me on how to check the difference(in days) between two dates.
    say like checking the day difference between yesterday and today.
    PHP Code:
    function date_diff($date1$date2){

    //i'm stuck here...
    //some code please...

    return $diff

    thanks in advance
    Last edited by modpluz; Apr 21st, 2006 at 06:41 AM.
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: PHP DateDiff()

    Since you have PHP in the thread title, I'm assuming that is the language you are using. If not, PM me and I will move it to the appropriate forum.

    Moved from the CodeBank

  3. #3

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: PHP DateDiff()

    yes, i'm using PHP
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  4. #4

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: PHP DateDiff()

    oh..i'm sorry thought i was posting in the right forum.
    thanks Hack
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  5. #5
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: PHP DateDiff()

    Found this in the comments in the PHP docs.
    Quote Originally Posted by http://uk2.php.net/manual/en/function.date.php
    I needed to calculate the difference between two dates in days based on current date and a date from the DB.

    This will be used to check if a members subscription has lapsed ( i.e 365 days have passed ).

    Here's the (simple) code:
    PHP Code:
    //calculate the difference between two dates in days.
    $regDate=strtotime("July 15, 2005"); //will come from DB
    $curDate=mktime(); //current UNIX timestamp.
    $diff$curDate $regDate//date diff in seconds
    $diff $diff 86400//date diff in days
    echo $diff//will be used to check member subscription 
    hope it helps someone.

  6. #6

    Thread Starter
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: PHP DateDiff()

    thanks but i found another script that checks date difference in months, years, days, weeks and more. though, i have to modify it to suit my needs.
    thanks anyway much appreciated.
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width