RE: time stamp

From: Date: Wed, 28 Aug 2002 23:18:09 +0000
Subject: RE: time stamp
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114434@lists.php.net to get a copy of this message
Thank you David Lopez and David Robley. That was what I was looking for. Here is how I used it. $date=getlastupdatetime(array("team_id" => $team_id,
                                "season" => $season,
                                "div_id" => $div_id));
echo "$date"; function getlastupdatetime($a){
        extract($a);
        $result=mysql_query ("SELECT MAX(UNIX_TIMESTAMP(updated)) as epoch_time FROM games
                                WHERE (hteam='$team_id' OR vteam='$team_id')
                                AND sea_id = '$season' AND div_id = '$div_id'");
        $date = mysql_result ($result, 0, 0);
        if(!$date){
                return;
        }else{
                return date("l dS of F Y h:i:s A O",$date);
        }
} Which gives me the following line: Wednesday 28th of August 2002 06:00:06 PM -0500 I was doing the following which was a bit more code and I wanted to use a little less code. Plus it should make the search and processing quicker. $date=getlastupdatetime(array("team_id" => $team_id,
                                "season" => $season,
                                "div_id" => $div_id));
echo "$date"; function getlastupdatetime($a){
        extract($a);
        $result=mysql_query("SELECT updated FROM games WHERE (hteam='$team_id' OR vteam='$team_id')
                                                AND sea_id = '$season' AND div_id = '$div_id'");
        $b=0;
        while(($row=mysql_fetch_object($result))){
                if($row->updated > $b){
                        $b=$row->updated;
                }
        }
        $date=$b;
        $year=substr($date,0,4);
        $month=substr($date,4,2);
        $day=substr($date,6,2);
        $hour=substr($date,8,2);
        $min=substr($date,10,2);
        if($hour >= 12){$ap = "pm";}else{$ap = "am";}
        if($hour > 12){$hour = $hour-12;}
        if(!$month){
                return "nothing";
        }else{
                return "$month-$day-$year $hour:$min $ap<br>";
        }
*/ } Thank Again Steve At 08:28 AM 8/28/2002 -0700, you wrote:
Steve Try: SELECT MAX(field_timestamp) from table1; David -----Original Message----- From: Steve Buehler [mailto:steve@vespro.com] Sent: Tuesday, August 27, 2002 5:21 PM To: mysql; PHP Subject: time stamp I am using PHP with MySQL and have a timestamp field in my db table. What would be the easiest way to get the newest timestamp out of the db? Thanks in Advance Steve -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3 --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual)
   http://lists.mysql.com/          (the list archive)
To request this thread, e-mail <mysql-thread118145@lists.mysql.com> To unsubscribe, e-mail <mysql-unsubscribe-r9374c=motorola.com@lists.mysql.com> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ow3

« previous php.general (#114434) next »