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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:40:21+00:00 2026-06-14T04:40:21+00:00

I have two strings containing time, like this: ‘ftime1′ => string ’17:44’ (length=5) ‘ftime2’

  • 0

I have two strings containing time, like this:

  'ftime1' => string '17:44' (length=5)
  'ftime2' => string '18:19' (length=5)

I need to calculate the difference between frime2 and ftime1, so result is in minutes.

I have tried

 $struct[$i]['ttime'] =  time($struct[$i]['ftime2']) - time($struct[$i]['ftime1']);
 $struct[$i]['ttime2'] =  strtotime($struct[$i]['ftime2']) - strtotime($struct[$i]['ftime1']);
 $struct[$i]['ttime3'] =  $struct[$i]['ftime2'] - $struct[$i]['ftime1'];

Which result in:

  'ttime' => int 0
  'ttime2' => int 2100
  'ttime3' => int 1
  • 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-14T04:40:22+00:00Added an answer on June 14, 2026 at 4:40 am

    strtotime converts string into timestamp which is on seconds..so the difference will also be in seconds..do / 60 for minutes..

    (strtotime($struct[$i]['ftime2']) - strtotime($struct[$i]['ftime1'])) / 60;
    

    and time function does not behave that way, it returns current Unix timestamp, and doesn’t take any argument..

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

Sidebar

Related Questions

Okey, I have two strings containing numbers like shown here using debugger: String 1
I have two equal length strings containing 1's and 0's. Each string is 128-bits
Let's say I have two strings like this: XABY XBAY A simple regex that
I have two vectors containing strings. I want to compare each string of vector1
I have a string say 123dance456 which I need to split into two strings
I have two strings containing a date like so start_date = 'Sun Sep 16
I have two Perl string variables containing date values. I want to check whether
I have two strings String s1=426F62; String s2=457665; The strings are in hex representation.
I have two arrays, each containing strings. The first array is a list of
I have two strings containing letters and numbers separated by spaces. ex String1elza7ma wa2fa

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.