Link to home
Start Free TrialLog in
Avatar of bilgehanyildirim
bilgehanyildirim

asked on

Converting $limit_time = time() - 300

We are running e web site, which has an online user counter. This is the php code placed on the site.
      
                $limit_time = time() - 300; // 5 Minute time out. 60 * 5 = 300      
      $sqla = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time GROUP BY ip_address") or die (mysql_error());
      if ($sqla == TRUE)
      {
            $visits = mysql_num_rows($sqla);
      }
      else
      {
            $visits = 0;
      }

can someone convert $limit_time to a variable which delphi can understand..
Avatar of Ivanov_G
Ivanov_G
Flag of Bulgaria image


   hey man .... this is the Delphi section and your code is PHP....

   Anyway .... you can format the date to string .... use date() function

   string date ( string format [, int timestamp])

   Let's say
   
        $delphi_var = date("m.d.y H:i:s", $limit_time);  // you date will be string in format 24.04.2004 00:56:36

   From Delphi you can use StrToDateTime function ....
Avatar of bilgehanyildirim
bilgehanyildirim

ASKER

Sorry but this is a question regarding delphi. May be I couldn't understand.

On my site I can run thus sql
$sqla = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time GROUP BY ip_address") or die (mysql_error());

But in my delphi project I could't convert $limit_time = time() - 300 to a string so that I could use it like

sql := 'SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >='+Converted_Time+'GROUP BY ip_address';

I think this is a DELPHI question ;)

   use the MySQL function DATE_FORMAT

  Example :

  SELECT DATE_FORMAT('2003-10-03', GET_FORMAT(DATE, 'EUR')

  This is string...
  I am not quite sure if there was function DATETIME_FORMAT. Please check the Documentation, because I don't have it now....
didn't work mate.

   which part exactly don't work ?
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial