Questions tagged [microtime]

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the microseconds range.

Anything related to programming languages functions (or other similar facilities) allowing the retrieval of the current time with a resolution in the microseconds (µs) range.

103 questions
1
vote
0 answers

How to pass microtime(true); (php) in an html form

and then i want to call a php file with a submit button so i can know how many times it took to the person to take the test

Question 187 : Je suis sûr…

1
vote
2 answers

PHP microtime() is correct?

I have used microtime() to check code execution time. But it seems very strange like time tracked is not correct. So in my test.php, I have code like following: $debug = true; $start = microtime(true); $newline = "
"; ... if ($debug) { …
Codemole
  • 2,649
  • 4
  • 19
  • 40
1
vote
1 answer

Can $_SERVER["REMOTE_PORT"] be repeated for more than one device at the same time

I try to make function that generate random id using $_SERVER["REMOTE_PORT"] and microtime() , so i ask if if $_SERVER["REMOTE_PORT"] Can be repeated for more than one device at the same time
bnabriss
  • 89
  • 6
1
vote
1 answer

Need a timestamp with microseconds as Decimal

Currently I'm using time.time() to create timestamps that include microtime. But primarily I'm comparing these against a decimal and time.time() returns a float. Currently I convert the value from float to decimal when needed: if type(stamp) ==…
Shane H
  • 3,103
  • 5
  • 24
  • 28
1
vote
0 answers

measure execution times of function

PHP $totalTimeFunction=0; function f1() { $t1=microtime(true); for($i=0;$i<900;$i++) {} $t2=microtime(true); $p=($t2-$t1); $GLOBALS['totalTimeFunction']+=$p; } …
ashkufaraz
  • 4,730
  • 4
  • 46
  • 69
1
vote
3 answers

PHP microtime() conversion to microseconds

I want to get seconds and microseconds in one variable using the microtime(). If I do this: $initial_time = microtime(); echo (explode(' ', $initial_time)[1]) . "\n"; echo (explode(' ', $initial_time)[0]) . "\n"; echo (explode(' ',…
1
vote
1 answer

How do I get many decimal places out of php microtime(true)?

In part of my code when I print microtime(true) it gives me a number like this 1410876482.803832 (6 decimal places), but other times it gives me a number like this 1410876484.86 (2 decimal places). How do I get it to consistently give my 6 decimal…
Drew LeSueur
  • 16,653
  • 27
  • 85
  • 96
1
vote
2 answers

PHP microtime() accuracy (zeroes at the end)

I've got two "similar" questions about microtime accuracy. 1) As was suggested in PHP online documentation, to get time in microseconds, I'm using a following code with microtime() function (looped):
Jacek Kowalewski
  • 2,551
  • 2
  • 19
  • 33
1
vote
1 answer

Finding Nano Time in Windows using PHP

I would like to create a unique id in php.I used uniqid() but microtime is not helping because the function is inside a loop and a set of consecutive results are exactly the same!! So i am wondering if i can use nano time.In linux it possible…
Nidhin David
  • 2,211
  • 2
  • 30
  • 37
1
vote
1 answer

PHP: How to echo remaining time in minutes from microtime

The following shows time in seconds, and want it in minutes, how do i convert to minutes? $query = "SELECT * FROM messages WHERE ip = '$ip' AND mtime >= NOW() - INTERVAL 5 MINUTE ORDER by mtime DESC"; $result = mysql_query($query); if…
Relm
  • 6,458
  • 16
  • 56
  • 101
1
vote
1 answer

PHP microtime returning different results

I seem to be having a strange issue when using the microtime function in PHP. On my index.php I have the following $.ajax({ url:'loadtime.php', datatype:"application/json", type:'get', data: "host=http://www.mywebsite.com", success:function(data){ …
1
vote
2 answers

PHP Converting ASCII Date/Time Stamps to Unix Times With Microseconds

I have two ASCII date time stamps. Ultimately I want to get the difference in seconds and milliseconds. I've tried using the DateTime class, as well as the Date() function. Both of these seem to truncate the microseconds, even though the docs for…
NotoriousWebmaster
  • 2,487
  • 5
  • 31
  • 43
1
vote
3 answers

Get Server time and insert into Mysql table via a Form

I have a form that posts the Date, Title, Message and Image into an SQL table. It all works fine, except the form, it has a field that I have to manually enter the date and time. What I want to know is how can I get the PHP to get the date & time…
Blackline
  • 243
  • 2
  • 5
  • 14
1
vote
2 answers

PHP microtime strange behavior

I was looking at execution time of some functions, but i have found that microtime is getting wrong, in one microtime() implementation №1 always first time is always getting more then second microtime() executing, when i testing one function and…
Jacob88
  • 95
  • 9
1
vote
1 answer

Measure total site loading time in PHP

I'm looking for a way to measure each step of a (HTTP) web request in php similar to Firebug's timeline or http://tools.pingdom.com. I can use a timer to measure the web requests, but I am looking for some function in PHP that can give me the…
el Fo
  • 9
  • 4