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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:37:14+00:00 2026-05-20T03:37:14+00:00

The situation I’ve got two timestamps. One with the start time and one with

  • 0

The situation

I’ve got two timestamps.

One with the start time and one with the end time.

The start time is: 04:43:37
The end time is: 11:59:59

Now I am trying to get the difference between the dates like this:

//define timestamps
$start_time     = 1297698217;
$end_time      = 1297724399;
$time_diff    = $end_time - $start_time;

//display times and difference
echo 
    '<b>Start time:</b> ' . date('d-m-Y h:i:s', $start_time) . '<br />' .
    '<b>End time:</b> ' . date('d-m-Y h:i:s', $end_time) . '<br />' .
    '<b>Time difference::</b> ' . date('h:i:s', $time_diff);

The result

Start time: 14-02-2011 04:43:37
End time: 14-02-2011 11:59:59
Time difference: 08:16:22

The problem

Now the problem is that the result should be 07:16:22. I've tried this with different times, but every time I'm getting the same result. One hour too much difference.

Is there an expert willing to help?

  • 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-20T03:37:14+00:00Added an answer on May 20, 2026 at 3:37 am

    The last one should be gmdate instead of date:

    '<b>Time difference::</b> ' . gmdate('h:i:s', $time_diff);
    

    date adjusts for your current locale, which appears to be GMT+1. gmdate does not make that adjustment.

    I’m assuming that you’re only planning to use this for time differences less than 24 hours.

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

Sidebar

Related Questions

Situation: One WebApplication, two site collections. Both site collections have the same type and
Situation: I got one input field and it needs to check if the input
Situation: I am trying to construct a simple method that accepts two different integers
Situation is simple. I need to wrap text around two inline objects (buttons with
Situation: I am trying to write a efficient query using "LIKE" statement to look
Situation I've got a worker thread that's being triggered by a condition_variable to do
Situation: I have a multithreaded program written in C. If one of the threads
Situation: I got news. NEws are posted in multiple categories. Issue: How to store
Situation: Large company with several internal Java applications that launched via Java Web Start
Situation: I have website which calls WCF Service and i'm trying to understand it..

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.