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

  • SEARCH
  • Home
  • 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 8454955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:09:40+00:00 2026-06-10T12:09:40+00:00

I have looked everywhere for a simple answer to this but I have not

  • 0

I have looked everywhere for a simple answer to this but I have not been able to find a solution that either works or meets my requirements.

I am looping through data, that looks similar to this:

Array
(
    [0] => 4c36fd909b37208b
    [1] => event:
    [2] => start_scan
    [3] => 2012-08-17 12:01:15
)
Array
(
    [0] => 4c36fd909b37208b
    [1] => sysaction:
    [2] => lower_device
    [3] => 2012-08-17 12:01:19
)
Array
(
    [0] => 4c36fd909b37208b
    [1] => event:
    [2] => how_to_use_displayed
    [3] => 2012-08-17 12:01:46
)
Array
(
    [0] => 4c36fd909b37208b
    [1] => event:
    [2] => scan_displayed
    [3] => 2012-08-17 12:01:59
)
Array
(
    [0] => 4c36fd909b37208b
    [1] => sysaction:
    [2] => layer_1_display_on_recognition
    [3] => 2012-08-17 12:02:23
)

I want to work out the time between two dates and the result needs to be in the format HH:MM:SS.
In the example data above, I need the difference between 2012-08-17 12:01:15 and 2012-08-17 12:02:23, which should be 00:01:08.

I have tried to use the code from here: http://www.if-not-true-then-false.com/2010/php-calculate-real-differences-between-two-dates-or-timestamps/ but it keeps returning 00:00:20

I have also tried this (where the date in the first array is saved as $xpTime and the date in the last array is set to $xpEndTimeTmp):

$start = new DateTime($xpTime);
$end = new DateTime($xpEndTimeTmp);
$diff = $start->diff($end);
$xpDuration = date('H:i:s', strtotime($diff->h.':'.$diff->i.':'.$diff->s));

But that seems to be working either (it returns the same hour, minute and a different second).

I hope someone can help me, tell me what I am doing wrong, or has sample code that could that could set me on the right track!

  • 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-06-10T12:09:42+00:00Added an answer on June 10, 2026 at 12:09 pm
    $t1 = '2012-08-17 12:01:15';
    $t2 = '2012-08-17 12:02:23';
    
    echo gmdate("H:i:s", strtotime($t2) - strtotime($t1));
    

    Result

    00:01:08
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked everywhere on the internet and can not find this answer. Do
I have looked everywhere and cannot find any simple solution to this. It must
I have looked everywhere for this and just cannot find the answer. I have
I have looked everywhere but have not found a problem similar to this. I
I am new so this is probably simple but I have looked everywhere and
I've looked everywhere but cannot find an answer. How can I check that if
Have looked quite hard for this answer but having no luck. I have 3
I believe this may be a simple question, but I've looked everywhere and tried
So, I have looked everywhere for a solution to this problem I have and
I have looked everywhere and it seems that it is currently not possible to

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.