Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Converting $limit_time = time() - 300

Posted on 2004-04-23
Medium Priority
Last Modified: 2010-04-05
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);
            $visits = 0;

can someone convert $limit_time to a variable which delphi can understand..
Question by:bilgehanyildirim
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 12

Expert Comment

ID: 10904189

   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 ....

Author Comment

ID: 10904214
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 ;)
LVL 12

Expert Comment

ID: 10904294

   use the MySQL function DATE_FORMAT

  Example :


  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....
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 10913689
didn't work mate.
LVL 12

Expert Comment

ID: 10915771

   which part exactly don't work ?
LVL 17

Accepted Solution

geobul earned 750 total points
ID: 10929799

Try this:

function UnixTimeToDateTime(const UnixTime: Integer): TDateTime;
  FileTime: TFileTime;
  SystemTime: TSystemTime;
  I: Int64;
  // first convert unix time to a Win32 file time
  I := Int64(UnixTime) * Int64(10000000) + 116444736000000000;
  FileTime.dwLowDateTime := DWORD(I);
  FileTime.dwHighDateTime := I shr 32;

  // now convert to system time
  FileTimeToSystemTime(FileTime, SystemTime);

  // and finally convert the system time to TDateTime
  Result := SystemTimeToDateTime(SystemTime);

Regards, Geo

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question