Comparing timestamps

Discussion in 'PHP' started by adzeds, Feb 2, 2010.

  1. #1
    I am working on a small script that is looking to see if one time is more than 30 minutes after another time.

    It is trying to work through some of my web stats to see if the visitor is a new visit.

    It does not seem to be working though.
    Hope you can help, here is my code:

    $accessed = mysql_result($Result,0,"access_time");
    			    list($date, $time) = explode(' ', $accessed);
        				list($year, $month, $day) = explode('-', $date);
       					list($hour, $minute, $second) = explode(':', $time);
        						$dateaccessed = mktime($hour, $minute, $second, $month, $day, $year);
    							$temptime = strtotime("30 minutes", $dateaccessed);
    								if($dateaccessed > $temptime) 
    								{
    								$newvisit = "Y";
    								} else {
    								$newvisit = "N";
    								}
    PHP:
     
    adzeds, Feb 2, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How is your date/time stored? What format is it in???
     
    JAY6390, Feb 2, 2010 IP
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $newvisit = (strtotime(mysql_result($Result, 0, 'access_time')) > time() - 1800) ? 'N' : 'Y';
    PHP:
     
    SmallPotatoes, Feb 2, 2010 IP
  4. adzeds

    adzeds Well-Known Member

    Messages:
    1,209
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    100
    #4
    problem solved thanks for all your help!
     
    adzeds, Feb 2, 2010 IP