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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:24:09+00:00 2026-05-23T21:24:09+00:00

I was just going through some code and was wondering if it is bad

  • 0

I was just going through some code and was wondering if it is bad to call time() multiple times on a page?

Yes, I know that it will work when called repeatedly, but will there be a big speed difference?

Option #1: Call time() whenever you need the current Unix timestamp.

Option #2: Set a variable $timestamp = time(); and call the variable whenever the time is needed.
  • 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-23T21:24:09+00:00Added an answer on May 23, 2026 at 9:24 pm

    That depends on the situation. Some scripts run for more than a few seconds, some could run for hours. Then the new value of time() would be wanted.

    If a difference in time that is shorter than the time it takes for your php code to execute won’t cause any problems then you might as well use Option #2 since it is slightly faster. But, the speed difference is negligible unless you make tons of calls to time().

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

Sidebar

Related Questions

I'm going through some new code I just wrote and adding NDoc sytle comments
I'm going through my app, trying to clean up some code that sends e-mails.
When going through some sample code, notice that setting the main Window Title in
I am new to C++. I was just going through some code and got
Here's some code in a django tutorial that I'm going through. I've never come
I have some legacy code I'm going through, and i just found a join
Just going through the sample Scala code on Scala website, but encountered an annoying
I recently was given some code in c# ASP.NET and I was going through
I am going through some pl/sql code with no comments. Trying to make sense
I was just going through some codes of C++. Where in I came across

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.