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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:09:50+00:00 2026-05-18T07:09:50+00:00

I want to find the time difference between a mysql timestamp and the time

  • 0

I want to find the time difference between a mysql timestamp and the time now in php.

$timesince = strtotime("now") -  $row['DateTime'];

This is my attempt at doing it but it doesn’t seem to work.

Also, really ideally I’d like the output to be in a nice format like: 34 minutes ago,2 hours 5 minutes ago 4,days 2 minutes ago etc.

Really, really appreciate any help on this.

  • 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-18T07:09:51+00:00Added an answer on May 18, 2026 at 7:09 am

    strtotime("now") returns the time as seconds since the Unix epoch, i.e. an integer. A mysql “timestamp” field is going to be YYYY-mm-dd HH:mm:ss. You first need to get those to be the same format. I’d recommend selecting the mysql timestamp field as UNIX_TIMESTAMP(DateTime) so it returns an integer, and then you’ll be able to do your math to get $timesince in seconds.

    Then, like @Derek Adair said, check out the PHP Date Object

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

Sidebar

Related Questions

I want to find time difference between two date and then compare the difference
I want to find difference between two time-components, but I am not getting what
I want to find out the difference between two Dates (in terms of minutes)
Let's say I want to find out the difference in seconds between two times.
I want to find a sql command or something that can do this where
so I have these two time stamps in PHP 1253339331 1253338959 I want to
I am new in Android.I can't find any way to calculate the time difference.So
I have two NSDate objects and I want the difference between the two and
I want to find records on a combination of created_on >= some date AND
I want to find a way to develop database projects quickly in Visual Studio.

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.