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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:49:59+00:00 2026-05-20T10:49:59+00:00

Quick embrassing question. I have been looking for a PHP function that would calculate

  • 0

Quick embrassing question.

I have been looking for a PHP function that would calculate the difference between two timestamps and output the result based on given parameters such as

the diff in years only, diff in months only, diff in days only, etc etc

The function I made has been quite buggy and I haven’t found a good one on the Net.

Please assist.

Thanks

  • 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-20T10:50:00+00:00Added an answer on May 20, 2026 at 10:50 am

    Please take a look at DateTime::diff()

    DateTime::diff — Returns the difference between two DateTime objects

    You can format the output to anything you want it to be

    (Provided an extra answer despite of the duplicates because they use strtotime & math and that doesn’t always work out well or is a nice way to do it. Using a core function of php seems nicer to me)

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

Sidebar

Related Questions

Quick question. What do you think, I have a few sites that use a
Quick question, I was curious if there is any difference between a database table
Quick question (I think). I have users, and I would like to allow them
Quick question: Would it be a good or a bad idea to implement my
Quick question. There is a legacy website (that is not under my control and
Quick question: is there a way to provide a closure in PHP to some
Quick question, hopefully I am just missing something simple. Ok I have one class
quick symfony / propel question. I have the following propel collection route: api_offer: class:
quick question really: I have this code: using System; using System.Collections.Generic; using System.Linq; using
Quick question: what is the compiler flag to allow g++ to spawn multiple instances

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.