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.

110 questions
7
votes
1 answer

laravel get microtime from database

In a MySQL database I have a datetime field stored like this: 2015-05-12 13:58:25.000508 But when I execute this query, for example: $query = SdkEvent::with('sdkEventStack'); if (isset($params['CO_ID']) && $params['CO_ID'] != "")…
karmous
  • 197
  • 3
  • 12
6
votes
2 answers

gettimeofday() always accessible?

I've tried Google, php.net and the php mailinglist's archives, but I can't find what I'm looking for. Maybe it's obvious, or maybe nobody wonders about this... For years, I've used microtime() to get the current time including the microseconds.…
lugte098
  • 2,271
  • 5
  • 21
  • 30
6
votes
3 answers

Is using microtime() to generate password-reset tokens bad practice

In PHP I've noticed some frameworks make use of the microtime() function to generate password reset tokens as in: $token = md5(microtime()); Is this a security issue? If the attacker is able to synchronize the clocks with the server to a degree…
user2072710
  • 77
  • 1
  • 7
5
votes
3 answers

Get Time Ticks in PHP

Consider this line of code in C# ordernumber.Value = DateTime.Now.Ticks.ToString(); How to get same ordernumber.Value in PHP $ordernumberValue = microtime(); //? I try to this echo microtime(true) * 10000000; But get result string.length was…
user1859327
  • 71
  • 1
  • 1
  • 5
5
votes
2 answers

microtime to standard date format

I Have some values which are milliseconds since epoch i.e. microtime(true) in my MySQL database these are got out as strings I need to convert them over to a standard PHP date() $updated = 1349697975.9381; $nUpdated = date($updated, "l jS F \@\ g:i…
Justin Erswell
  • 688
  • 7
  • 42
  • 87
5
votes
2 answers

php time() and microtime() do sometimes not concord

While logging some data using microtime() (using PHP 5), I encountered some values that seemed slightly out of phase in respect to the timestamp of my log file, so I just tried to compare the output of time() and microtime() with a simple script…
zoyd
  • 51
  • 1
  • 2
4
votes
3 answers

JS microtime vs php microtime

i'm using a plugin for a ganttchart. i feed the plugin with json: Plugin: GitHub - JQuery Gantt { "name": "Zbigniew Kowalski", "desc": "Administrator", "values": [ {"from": "/Date(1310508000000)/", "to": "/Date(1311026400000)/", "desc":…
Jens
  • 345
  • 1
  • 6
  • 19
4
votes
1 answer

PHP Output Buffer Benchmark (microtime inaccurate when used with usleep?)

I post a strange behavior that could be reproduced (at least on apache2+php5). I don't know if I am doing wrong but let me explain what I try to achieve. I need to send chunks of binary data (let's say 30) and analyze the average Kbit/s at the end…
nunja
  • 41
  • 1
  • 3
4
votes
2 answers

Measuring a duration with microtime results randomly in zero

I am having a loop like this:
n.r.
  • 831
  • 1
  • 11
  • 30
4
votes
2 answers

php microtime() format value

PHP's microtime() returns something like this: 0.56876200 1385731177 //that's msec sec That value I need it in this format: 1385731177056876200 //this is sec msec without space and dot Currently I'm doing something this: $microtime = …
Matías Cánepa
  • 5,770
  • 4
  • 57
  • 97
4
votes
3 answers

Increasing the number of iterations of a simple loop by 1 significantly increases execution time

I need some help to figure out a situation with a webserver regarding execution time. I've noticed a problem when the server returns a higher number of characters than ~41000 - around 40KB. So I did a script:
B D
  • 41
  • 2
3
votes
1 answer

How to get duration in microseconds

I want to measure how long a specified part of my php script takes, e.g. $startTime = microtime(true); //some operations which needs 0.1 to 100 seconds to run $endTime = microtime(true); How can I get the duration in microseconds as an integer?…
Roland
  • 488
  • 1
  • 4
  • 13
3
votes
1 answer

What's the microseconds precision in PHP under different OSes?

If I do: echo microtime(true); I get the following results: On my local Windows development environment I get a 4 digit precision (1310564569.4162 for example). On my live CentOS (Linux) server I get a 2 digit precision (1310564569.41 for…
AlexV
  • 22,658
  • 18
  • 85
  • 122
3
votes
2 answers

PHP microtime()

Here is my code: ".$len."
"; $micro; $i = 0; while ($time{$i} != " ") { $micro{i}=$time{i}; echo $micro{i}; $i=$i+1; …
Anant
  • 149
  • 3
  • 9
3
votes
1 answer

Node.js: When does process.hrtime start

What is the starting time for process.hrtime (node.js version of microTime)? I couldn't find any event that starts it. Is the timestamp of the start saved anywhere? I need my server to be able to get latency to client both ways and for that, I need…
Anagmate
  • 71
  • 1
  • 4