Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP MYSQL TIMESTAMP

Posted on 2006-11-24
3
Medium Priority
?
1,202 Views
Last Modified: 2013-12-12
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
Comment
Question by:cfans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 18009271
SELECT DATEDIFF(CURRENT_DATE(), yourTimestampField) AS daysDifference FROM theTable;
0
 

Author Comment

by:cfans
ID: 18009420
Is there an alternative to this?  The version of MySQL I am using doesn't seem to support that function.
0
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 600 total points
ID: 18009503
SELECT TO_DAYS(CURRENT_DATE()) - TO_DAYS(yourTimestampField) AS daysDifference FROM theTable;
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question