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 922199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:59:26+00:00 2026-05-15T18:59:26+00:00

I have a globalish variable which is $VARcurrenttime = time(); then I normally call

  • 0

I have a globalish variable which is $VARcurrenttime = time(); then I normally call that variable when computing anything with that timestamp (which is a lot). Someone suggested to me that using time() instead of the variable would be somewhat faster. I don’t really know but could someone advise me on whether I would bother changing this or not?

  • 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-15T18:59:27+00:00Added an answer on May 15, 2026 at 6:59 pm

    This:

    /* Real-World Time is 2010/01/01 12:00:00 */
    $var = time(); /* $var = 2010/01/01 12:00:00 */
    $a = doSomething($someOtherVar, $var); /* Passes 2010/01/01 12:00:00 */
    $b = doSomething($someOtherVar, $var); /* Passes 2010/01/01 12:00:00 */
    $c = doSomething($someOtherVar, $var); /* Passes 2010/01/01 12:00:00 */
    /* Real-World Time is 2010/01/01 12:00:40 */
    

    takes almost exactly the same but very-slightly less time as this:

    /* Real-World Time is 2010/01/01 12:00:00 */
    $a = doSomething($someOtherVar, time()); /* Passes 2010/01/01 12:00:00 */
    $b = doSomething($someOtherVar, time()); /* Passes 2010/01/01 12:00:07 */
    $c = doSomething($someOtherVar, time()); /* Passes 2010/01/01 12:00:23 */
    /* Real-World Time is 2010/01/01 12:00:40 */
    

    but it is also very different because even though the real-world time for both of them is about the same, one is grabbing the latest time each call. Depending on your needs this is either desirable or undesirable.

    As time() has to compute something (even if it is just a system lookup) I’m going to assume it is slower than referencing a variable, but the difference is going to be so close to negligible that it is completely not worth worrying about – what is more important is do you need to use the same timestamp multiple times or the current time multiple times?

    The real-world analogy is comparing writing down the time and then looking at that number everytime someone asks you “what’s the time” or checking a watch. They are going to take around about the same amount of time but give very different answers.

    Ultimately you are comparing the speeds of two completely different things. You are not comparing the speeds of two ways to do the same thing. It’s like me asking you, which is faster – getting an aeroplane overseas or driving a car to your work. The answer is one is faster, but they do completely different things.

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

Sidebar

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.