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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:59:45+00:00 2026-06-04T06:59:45+00:00

The future time is : 2012-05-26 00:00:00 supposed there are three variable: $hour $minute

  • 0

The future time is :2012-05-26 00:00:00

supposed there are three variable: $hour $minute $second

now, i want to using the future time subtract now time. then give the left hour to $hour,give the left minute to $minute,give the left second to $second.

i am sorry i am new of php, now i get stucked how to do the math operation ? thank you

  • 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-04T06:59:45+00:00Added an answer on June 4, 2026 at 6:59 am

    The following are the math operations for the difference in hours,minutes and seconds

    $future_datetime = '2012-05-26 00:00:00';
    $future = strtotime($future_datetime); //future datetime in seconds
    $now_datetime = date('Y-m-d H:i:s');
    $now = date('U'); //now datetime in seconds
    
    //The math for calculating the difference in hours, minutes and seconds
    $difference = $future - $now;
    $second = 1;
    $minute = 60 * $second;
    $hour = 60 * $minute;
    $difference_hours = floor($difference/$hour);
    $remainder = $difference - ($difference_hours * $hour);
    $difference_minutes = floor($remainder/$minute);
    $remainder = $remainder - ($difference_minutes * $minute);
    $difference_seconds = $remainder;
    echo "The difference between $future_datetime and $now_datetime is $difference_hours hours, $difference_minutes minutes and $difference_seconds seconds";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a time in the future when I want a notification to occur
I have a $time variable set some time in the future. In this format
Are there any future plans to replace selenium and watir with mechanize + johnson?
i have a date in the future and i want to find out how
I'm having an hard time trying to parse date in the future, and I
in my app , I used DateField to get future time and i save
For a while I had been using a raw MySQL NOW() function to record
I am using time picker for my app which sends sms based on a
I submit some some Future tasks using a CompletionService wrapped round a 2 thread
This has been bugging me for some time now, I will greatly appreciate the

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.