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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:52:06+00:00 2026-05-12T22:52:06+00:00

I have a DATETIME for an entry in my database that is upcoming. I

  • 0

I have a DATETIME for an entry in my database that is upcoming. I want to know the difference in time between the the DATETIME and the current date/time in Days, Hours, Minutes, and Seconds. I thought I might be able to use the date function to do this, but perhaps I am wrong.

This was my approach:

$now = mktime(0, 0, 0, date("m"), date("d"), date("y"));
$entry_datetime = strtotime($row['end_auction']);

$difference = date("G, i, s",($entry_datetime - $now));
echo $difference;

The result i received is

13, 20, 00

but that doesn’t make any sense since the DATETIME in $row[‘end_auction’] is November 28th and today is November 19th, so much more than 13 hours apart.

How do I find the difference between the two values and how do I format it to appear as:

9 days, 10 hours, 32 minutes, and 20
seconds

Thank you in advance!

  • 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-12T22:52:07+00:00Added an answer on May 12, 2026 at 10:52 pm
    function datediff( $date1, $date2 )
    {
        $diff = abs( strtotime( $date1 ) - strtotime( $date2 ) );
    
        return sprintf
        (
            "%d Days, %d Hours, %d Mins, %d Seconds",
            intval( $diff / 86400 ),
            intval( ( $diff % 86400 ) / 3600),
            intval( ( $diff / 60 ) % 60 ),
            intval( $diff % 60 )
        );
    }
    
    print datediff( "24th November 2009", "now" ) . "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datetime column in db that I want to transform into a
I have a datetime field like that. <field name=rel_date type=date indexed=true stored=true default=NOW multiValued=false/>
I got a application where I use DateTime.MaxValue to indicate that a entry have
I ran across a blog entry that stated DateTime.Parse is COM dependent. I have
I'm trying to display the difference, in seconds, between the current server time and
I have a datetime called dispatched_time which I am subtracting from Time.now which results
I have a datetime.datetime property var. I would like to know if it is
I have a DateTime object I want to compare against an sql datetime field
I have a huge database that has several tables that hold several million records.
I have a database schema that stores one Page with many Revisions. Like a

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.