Results 1 to 2 of 2

Thread: php date help

  1. #1
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php date help

    Hi,

    I need to store a download date in a MySQL Database when a user makes an order, and check to see if that download date has expired when the user logs in in the future. What would be the best way to do this? timestamp?

    Is there a PHP function that can anaylze the timestamp (or some sort of date string) and check to see how much time is left?

    Example: User orders download access for 24 hours - Comes back 5 hours, 20 minutes later - It should tell him that he has 18 hours fourty minutes left.

    I just need help on the timestamp/php date/math function... I've got the database queries down.

    Thanks!

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Hmm...you could try something like this.
    PHP Code:
    //I am going to assume that the funtion getLast() returns the timestamp of
    //when they ordered the item
    $old getLast();
    $diff time() - $old;
    if(
    $diff >= 86400){
    //been longer than a day
    $return 'It has been to long';
    }
    else{
    $hours date('H',$diff);
    $minutes date('i',$diff);
    $return 'You have $hours hours and $minutes minutes left';
    }
    echo 
    $return

Bookmarks

Posting Permissions

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