Solved

PHP MYSQL TIMESTAMP

Posted on 2006-11-24
3
1,194 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
  • 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 150 total points
ID: 18009503
SELECT TO_DAYS(CURRENT_DATE()) - TO_DAYS(yourTimestampField) AS daysDifference FROM theTable;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now