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: you've got a .swf embedded in an html page, and when you click
The situation: I have a pieceofcrapuous laptop. One of the things that make it
Situation: Google has indexed a page in a forum. The thread is now deleted.
Situation: The UI of an app is based on a UISplitView with two UINavigationController
The situation: I have MySQL 5. I am trying to produce a report of
Situation: I have a simple XML document that contains image information. I need to
Situation: A PHP application with multiple installable modules creates a new table in database
Situation: text: a string R: a regex that matches part of the string. This
Situation: Site with content protected by username/password (not all controlled since they can be
Situation: Table TBL has ~10k entries for deletion, Table TBL has 14 child tables

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.