Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6146153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:54:21+00:00 2026-05-23T18:54:21+00:00

Not really, but I am running into an issue where once in a blue

  • 0

Not really, but I am running into an issue where once in a blue moon while running this script, my time results in a negative number. here is the part of the script where it is happening:

public function execute()
{
    $time1 = microtime();
    foreach($this->tables as $table)
    {
        if($this->buildQuery($table))
        {
            if($this->submitQuery($table))
            {
                $time2 = microtime() - $time1;
                echo "Sync Successful({$time2}s).. $table <br /> \n";
                //log
            }
        }
        else echo "No data to sync in $table";
    }    
}

As you would suspect.. there should be nothing wrong with subtracting second time from the first and getting a rough estimate of how long the process took.. However.. If I run it enough times, sometimes the results will print out the following:

Sync Successful(0.062936s).. users
Sync Successful(-0.86901s).. profile
Sync Successful(-0.798774s).. groups
Sync Successful(-0.718851s).. phonebook
Sync Successful(-0.711768s).. products
No data to sync in locations

This is very rare, but this is an exact output of my last result. So my questions would be:

How is this possible? resulting in a ‘negative’ when this should clearly should not happen..

What can I do to avoid this? Is there a better way to go about this? Is microtime() unreliable?

Can someone lend me a 1981 DeLorean DMC-12 capable of 88 mp/h?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:54:22+00:00Added an answer on May 23, 2026 at 6:54 pm

    You’re assuming the wrong data type. The manual page of microtime reads:

    By default, microtime() returns a string in the form “msec sec” […]

    So you’re actually subtracting only the msec values as both strings are converted to numbers before the actual subtraction takes place.

    Use microtime(true) to get float values:

    If get_as_float is set to TRUE, then microtime() returns a float […]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is not really a programming question but please bear with me as I
I'm not really sure how to ask this question, but I'll do my best.
This does not really apply to any language specifically, but if it matters I
I know this is possible but I'm not really sure where to start. Has
This is not really a question because I just solved the problem, but I
I have ran into a really annoying issue which gives me this error: The
This is my first time setting up teamcity and I am running into some
Running into an issue with some code I'm working on. This code is being
i try to use jquery .text() but not really work : Before <a id=group_name
I'm working on an ASP.NET website (MVC3 but not really important for my question)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.