Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Sutton-in-ashfield, Notts
    Posts
    117
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Timestamp Convert

    Can anyone tell me the problems with this?

    PHP Code:
            public function timestampConvert($timestamp){
                
    $difference time() - $timestamp;
                if(
    $difference 24) {
                return 
    "Today";
                }else{
                    
    $difference round($difference 24);
                    if(
    $difference 1) {
                    return 
    "Yesterday";
                    }
                }
            } 

  • #2
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    845
    Thanks
    15
    Thanked 10 Times in 10 Posts
    The timestamp is in seconds... so your line
    PHP Code:
    $difference time() - $timestamp;
                if(
    $difference 24) { 
    I am thinking the 24 means hours? If so that should actually be
    PHP Code:
    if($difference < (24*60*60)) 
    As goes with the rest of your script.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com


  •  

    Posting Permissions

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