0

Hi,

Please consider the below code.

<html>
<body>

<?php

$time1 = localtime();
echo $time1[0];


echo("<br /><br />");


/* HERE SOME CODES RELATED TO CERTAIN FUNCTIONS LIKE DISPLAYING OF SOME IMAGE ETC. IS EXECUTED. APPROXIMATELY IT TAKES 10 SECONDS FOR THE COMPLETE EXECUTION OF THESE FUNCTIONS. SINCE IT IS IRRELEVANT TO MY QUESTION, I REMOVED THEM FOR THE SAKE OF KEEPING THIS PIECE OF CODE SIMPLE.   */


echo("<br /><br />");


$time1 = localtime();
echo $time1[0];


?>

</body>
</html>

OK, now I get the following output when I execute the above code:

48

**** THE OUTPUT OF THE FUNCTIONS LIKE LOADING CERTAIN IMAGES.  NOTE: IT TAKES APPROX. 10 SECONDS FOR THIS OUTPUT TO COMPLETELY APPEAR ON THE SCREEN

48

Now, my question is:
In the beginning and ending of the code, I echoed localtime()[0] which displays the 'seconds' value of the current time. But in the middle of the code, I executed certain functions which took approx. 10 seconds to get executed. Then how come localtime()[0] present in the ending outputted the same value which it outputted in the beginning??

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by el33t
0

I suspect that it isn't taking anything like 10 seconds to execute the functions that you didn't show. That's a long time on a fast machine. Put a sleep command in just after all the code that you didn't show and I'll bet that you'll see a difference in the two values. The time until it displays might be quite long because of network transmission time or the time it takes the browser to deal with it but it may not be anywhere near that amount of time on the server. If you want to see how much time it is actually taking use / display the microtime before and after.

0

I suspect that it isn't taking anything like 10 seconds to execute the functions that you didn't show. That's a long time on a fast machine. Put a sleep command in just after all the code that you didn't show and I'll bet that you'll see a difference in the two values. The time until it displays might be quite long because of network transmission time or the time it takes the browser to deal with it but it may not be anywhere near that amount of time on the server. If you want to see how much time it is actually taking use / display the microtime before and after.

Ok, it seems you are right! I added that sleep command and got the correct time difference this time.

Thanks a lot for your time.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.