111 questions
0
votes
1
answer
158
views
Get execution time of symfony http client
I want to get the number of seconds an http request takes. I have this code:
$starttime = microtime(true);
$response = $this->httpClient->request(
'POST',
$endpoint,
[
'...
0
votes
0
answers
101
views
LARAVEL_START inconsistent with multiple queue workers
In my Laravel app, I want to add the job execution time to each job's log. To do this I am subtracting LARAVEL_START from the current microtime() like this:
$data['meta']['requestDuration'] = round((...
1
vote
1
answer
183
views
I have a C# function that I have to execute every 50ms. But execution of the function sometimes takes>50ms. How can I manage this problem? [duplicate]
In my C# script, I have a C# function that I have to execute exactly every 50ms for 20 seconds. I am doing this with a C# microtimer dll.
https://www.codeproject.com/Articles/98346/Microsecond-and-...
0
votes
1
answer
44
views
Why is it that when the number of loops is increased, the execution is faster than when the number of loops is small?
Why is this code is faster the executiont time:
$start_foreach = microtime(true);
$counter = 1;
foreach (range(1, 1000) as $number) {
$counter++;
}
$end_foreach = microtime(true);
$time_foreach = (...
0
votes
0
answers
264
views
microtime() or hrtime() for generating a unique number in a foreach loop
This has been asked before I think, but with key differences in the details...
So I want to group an array of product sub-arrays by a specific grouping value found in some sub-arrays. The grouping ...
0
votes
1
answer
223
views
PHP (poor man's profiler) incorrect hrtime() difference
I'm implementing so-called poor man's profiling in PHP and doing it pretty straightforward way as you would expect:
$start = hrtime(true);
// API request is more than 1 second long
$response = $this-&...
-3
votes
1
answer
87
views
Is there a microtime.h library for C
I have a C program that has #include <microtime.h> in the header, but when I compile it with GCC or g++, it shows the error -
fatal error: microtime.h: No such file or directory
2 | #include ...
0
votes
1
answer
56
views
Get latest from array of microtimes
I am looping through a list of files and grabbing their modified date, which is returned in microtime format:
int(1633986072)
int(1633971686)
int(1634014866)
int(1634000474)
I can loop through these, ...
1
vote
0
answers
21
views
convert Unixtime to microtime
The data aer in der MySql database, the dates in unixtime. I coulde save it ohterwise, the input from the user is a norlman date dd.mm.YYY, I transform it as a Unixtime in to the database.
Now I ...
0
votes
2
answers
3k
views
Angular 9 Issue: Unable to run the initial application
Can someone help me to resolve the following issue?
I am following the https://v8.angular.io/guide/setup-local#prerequisites document to set up the initial application on my windows machine but ...
0
votes
1
answer
55
views
Weird Issue on a benchmark in PHP
I have wrote this snippet to test the time that it takes to cast a string to integer and I tried this one here for fun but the result was so interesting.
<?php
$s = "123456789";
$t = microtime(...
0
votes
1
answer
38
views
How to get missing time to a microtime from another one, formatted (H:i:S) with PHP?
i am new to stackOverflow, i was wondering how could i get the missing time date to a microtime(true) starting from another microtime(true), and get it formatted like that (H:i:s).
This is my code:
$...
2
votes
1
answer
142
views
In PHP it possible to use microtime() inside another microtime()?
I have a loop with a number of functions
I want to check how long the entire loop runs, and also each of the functions within the loop
Is it possible to use a parent and many child microtime ...
0
votes
2
answers
166
views
Stop execution till the beginning of the next hour
I successfully find (i think) how many microseconds have to pass till the beginning of the next hour but usleep() function shows warning
Number of microseconds must be greater than or equal to 0
$...
0
votes
1
answer
1k
views
Convert microtime(true) to javascript date object
Can the value of PHP's microtime(true) be converted to a javascript date object, and the accuracy to be preserved ?
4
votes
2
answers
95
views
Measuring a duration with microtime results randomly in zero
I am having a loop like this:
<?php
ini_set('memory_limit', '16024M');
ini_set('set_time_limit', 9999);
ini_set('max_execution_time', 9999);
ini_set('display_errors', TRUE);
ini_set('...
0
votes
0
answers
51
views
microtime showing 1.52214531583E+12
I am using round(microtime(true) * 1000); for generating current timestamp in 13 digits.
But it is not returning me correct 13 digit values instead it return something like this:
1.52214531583E+12
...
0
votes
2
answers
1k
views
Update Input field value with javascript
I am trying to build a javascript function that will update an input field every second with a new number. This is essentially what I'm hoping my function can do, and hopefully someone can give me a ...
0
votes
1
answer
140
views
node.js reliable microtime setTimeout?
How do I shoot an event EXACTLY after given time in milliseconds? Is there any module for that? I was looking for it on google, but didn't find anything satisfactory...
1
vote
1
answer
2k
views
MD5 ($_POST['username'] + microtime()) says it encountered a non-numeric value since new PHP version
I reinstalled WAMP and now I have PHP version 7.1.9 (before this I had 7.0 x).
A part of the code doesn't work anymore without warning/notice reports.
- Warning: A non-numeric value encountered in
...
0
votes
1
answer
180
views
PHP MySQLi prepared statements select rows that are added to records in specific time
I'm having a similar error: PHP mysqli condition greater than or less than symbol error
But I don't find a solution to this since my application is a bit different.
I have following statement right ...
0
votes
1
answer
735
views
create unique string in php with base_convert and limited length
I need a string with max 6 length and mixed of number and alphabet. I checked:
How can I make short random unique keys, like YouTube video IDs, in PHP?
and
PHP generate a unique string
that was ...
-4
votes
1
answer
1k
views
Elapsed Time in PHP?
I've seen several questions on this topic, all with the same basic answer. Use microtime() to record the start and end time, then subtract. Mostly this works, except when the event spans the point ...
0
votes
0
answers
778
views
Postgresql how to store PHP microtime (true)
I am trying to store PHP microtime to postgres DB, i tried to use timestamp datatype however i got an error.
this is how i am trying to store it to BD (Laravel framework)
<?php
$...
0
votes
0
answers
143
views
PHP how to use micro-time as order id, need micro-time in 9 digit encode/decode formula.
I used http://www.epochconverter.com/date-difference
From 1/1/2000, 12:00:00 AM (epoch: 946665000)
To(current time) 8/11/2016, 12:00:00 PM (epoch: 1478586600)
Difference in seconds: 531921600
...
-3
votes
1
answer
1k
views
Find PHP microtime 1 day ago
How to find 1 day ago time in PHP microtime() format.
I am trying like this. But still showing the current time.
$date = date("Y-m-d H:i:s", strtotime('-1 day'));
$val = microtime($date);
2
votes
4
answers
2k
views
how to convert minutes into microtime
I have a session which contains microtime(true) value. like below:
Yii::app()->user->setState('portal_logged_time', microtime(true));
Now i want to add 15 minutes in above session, but it ...
0
votes
0
answers
304
views
PHP - how to generate different timestamps in the loop?
How can I loop an array and create different timestamp for each iteration?
$array = array(
1 => 'one',
2 => 'two'
);
foreach( $array as $key => $value ){
var_dump( "CONTENT_" . ...
0
votes
2
answers
348
views
PHP microtime - microseconds format
If PHP's microtime() function were to be executed at a point in time where the resulting microseconds are zero, what format does it result in?
Would it look like this?
0.00 1467926279?
Or this?
0 ...
0
votes
1
answer
156
views
memory_get_usage() & microtime()
Good day! I have this code:
final class bench
{
protected static $start_time;
protected static $start_memory;
public static function start()
{
self::$start_time = microtime(...
1
vote
1
answer
608
views
PHP microtime missing digits
In PHP, when using microtime(true), I am expecting to get in most cases 6 digits to the right of the decimal.
<?php
//version 5.5.31
$time = microtime();
$timeTrue = microtime(true);
var_dump($...
0
votes
1
answer
1k
views
How to format time difference with micro seconds
I want to get the time difference between the two times below. The format of the time difference should be hours minutes seconds and then micro seconds. I want the final answer in this format only.
$...
2
votes
2
answers
175
views
How to use Regex to match PHP time() or microtime() in a string?
I currently have a regex command which matches php time in a string:
preg_match( '/([a-z]+)_([0-9]{9,})\.jpg/i', $aName, $lMatches );
How can I modify this to also match microtime() in the same ...
-1
votes
1
answer
31
views
Need Help Creating BackUp directory
$backuparray = implode("|",$songarray1);
file_put_contents("backups/".microtime("tunes.txt"),$backuparray);
How do I get my backup directory to link a txt file using microtime , owner id , ...
1
vote
0
answers
75
views
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
<p class="Text"><font face="Arial"><font face="Arial">&...
0
votes
2
answers
364
views
PHP - Convert specific hour into microtime
I need to know how to convert 07:00pm of the current date in microtime. Sorry if this is a silly question but I cannot find the answer anywhere
1
vote
2
answers
447
views
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(...
0
votes
1
answer
1k
views
Php microtime() is not working on live site. Looking for workaround
I have Zend Server 6.3 and Php 5.4 on Windows. And system works very well. Now I moved code to live site, which runs Php 5.3.29 on Ubuntu Server with DirectAdmin. All other website are running well ...
11
votes
3
answers
46k
views
Get current timestamp in milliseconds [duplicate]
I want to get current timestamp with milliseconds in PHP something like below, in JavaScript I use Date.now()
1436030635348
I tried something like below:
$time = str_replace(".","",microtime(true))...
1
vote
1
answer
79
views
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
1
vote
1
answer
2k
views
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 ...
5
votes
3
answers
11k
views
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(...
2
votes
2
answers
928
views
Fetching data from mysql table using php microtime not working properly
I am displaying a long list of sales details from a table in mysql.
The problem is I am being able to fetch data only for a month. As soon as the month changes it doesnt display anything.
For ex: data ...
7
votes
1
answer
2k
views
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 (...
1
vote
0
answers
63
views
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;
}
$t1=...
0
votes
2
answers
11k
views
microtime in second with 2 decimals
I try calculate time of an act in second with 2 decimals.
protected function microtimeFormat($data)
{
$duration = microtime(true) - $data;
$hours = (int)($duration/60/60);
...
3
votes
1
answer
4k
views
Measuring the time of PHP scripts - Using $_SERVER['REQUEST_TIME']
Are this methods a reliable way to measure a script:
$time = ($_SERVER['REQUEST_TIME_FLOAT'] - $_SERVER['REQUEST_TIME']);
or
$time = (microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']);
Which one ...
0
votes
3
answers
272
views
Force to display regular decimal number
I'm running a benchmark test of doing nothing so the results is pretty fast.
Here is my code:
$time_start = microtime(true);
//Do Nothing...
$time = microtime(true) - $time_start;
echo 'Took '.$...
0
votes
1
answer
701
views
remove all strings from microtime and add minutes to it
im usng this code to get php microtime
$date = round(microtime(true) * 1000);
the echo result i get like this
1.42020381242E+12
how do i make sure the microtime is just numbers no special ...
1
vote
3
answers
2k
views
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)...