dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: date() help - calculate number of days elapsed

  1. #1
    Join Date
    Aug 2006
    Posts
    301

    date() help - calculate number of days elapsed

    i have a script that stores the date that a member joins using

    $date = date('d-m-Y');

    i want to be able to check the current date,
    and then find out how many days have past
    since the member's join date.

    ideally it should end up as

    $elapsed = 12;

    if 12 days have past.


    so i can just check $elapsed and if it is less than 30 days
    since the user joined i could offer a discounted purchase

    sort like this ...

    $cur_date = date('d-m-Y');

    function get_join_date(){

    //calculate the number of days elapsed,
    //and store it as a number in a variable
    //named $elapsed

    }

    if( $elapsed <= 30 ){
    //show discounted purchase link
    } else {
    //show regular purchase link
    }

    can anyone help with the code for the function?
    I'm assuming it is not as simple as subtracting the
    $cur_date from $join_date and storing it as $elapsed

    thanks,
    Michael.

  2. #2
    Join Date
    Jun 2006
    Location
    Down at the bottom of the garden
    Posts
    1,239
    Use time() and mktime() to form UNIX timestamps that can be subtacted from one another to get the diffrance.

  3. #3
    Join Date
    Jun 2006
    Posts
    472

  4. #4
    Join Date
    Aug 2006
    Posts
    301

    thanks

    Quote Originally Posted by aussie girl

    thanks all.

    thanks aussie girl, that works perfectly!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles