Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1206
  • Last Modified:

PHP MYSQL TIMESTAMP

Hello, I'm trying to figure out how to subtract timestamps.

I've got a TIMESTAMP in MYSQL and would like PHP to calculate the number of days it has been up until the current date.

How do I go about doing this?
0
cfans
Asked:
cfans
  • 2
1 Solution
 
snoyes_jwCommented:
SELECT DATEDIFF(CURRENT_DATE(), yourTimestampField) AS daysDifference FROM theTable;
0
 
cfansAuthor Commented:
Is there an alternative to this?  The version of MySQL I am using doesn't seem to support that function.
0
 
snoyes_jwCommented:
SELECT TO_DAYS(CURRENT_DATE()) - TO_DAYS(yourTimestampField) AS daysDifference FROM theTable;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now