Jump to content

Date time comparisons


Paul-D

Recommended Posts

Thanks for these. These are useful functions but in my case I am extracting to date time values from different tables not in the same SQL so I think I need a PHP solution.

$a = "2018-08-26 12:20:00"

$b = "2018-08-27 13:30:05"

So $c would be either 1 day : 1 hour: 10 minutes: and 5 seconds OR 25 hours 10 minutes: 5 seconds.

Sorry not so strait forward.

Link to comment
Share on other sites

Oh, you want to do this in PHP.

One big question here: what about DST? In the US it will end Nov 4. If you had two dates, Nov 3 12pm and Nov 4 12pm, would you want the result to be 24 hours (because that's what it looks like) or 25 hours (because that's the actual difference)?

Link to comment
Share on other sites

29 minutes ago, Paul-D said:

These are useful functions but in my case I am extracting to date time values from different tables not in the same SQL so I think I need a PHP solution.

That shouldn't matter. You could run a query to get the first date/time and assign the value to a PHP variable. In your second query you could execute the TIMEDIFF() function where one argument is the PHP variable created earlier. The other argument would be the other date/time.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.