Page 1 of 1

print timestamp

Posted: Mon Mar 05, 2007 4:30 pm
by johnhelen
Hello

In a php script, I have a query to select a record from a database. I really want to know how long this query will take

So I want to print time stamp before and after this query (in miliseconds). However, php cannot print a timestamp value

Could you please help

regards
john

Posted: Mon Mar 05, 2007 6:26 pm
by feyd
PHP has time stamps in various forms internally. I can't see how PHP "cannot print" one.

Posted: Tue Mar 06, 2007 4:38 am
by Kieran Huggins
microtime() is what you're afrer:

Code: Select all

$time_start = microtime(true);

// query here
MySQL_query("SELECT * FROM table WHERE `bob`='yourUncle'");

$time_end = microtime(true);
$time = $time_end - $time_start;

echo "Query took $time seconds\n";

Posted: Tue Mar 06, 2007 2:28 pm
by RobertGonzalez
Everah | Moved to PHP code.

If you haven't already clicked on the microtime() function link, you should. Right up toward the top of the page is an example of doing exactly what you want to do.