sorry if the title isnt very clear, i just didnt know how to word it, anyways, the point of this topics is, that im wondering how to pull a quesry from the database and have it display either "Today", "Yesterday", "1 Day Ago", "4 days ago" ect ect, 4 in that last one being X ammount of days, i am trying to get it from the value of this feild in the database:
lastseen
which produces a value in the format of date and time like so:
2012-02-19 05:14:31
so my question is, how exactly would i do this, as im not very good with the time functions and quesrys in php.
Cheers if you can help, also if you need more explanations please just ask
there is certainly a function in SQL that lets you get the difference in days. then you can either use a SQL procedure to convert 0 into today and 1 into yesterday or you do that part in PHP.
PS. I deem "yesterday" and "1 day ago" synonymous
__________________
please post your code wrapped in [CODE] [/CODE] tags
well what i need help on is whats in my OP, basically converting the time stamp, from what it is, to something like "Yesterday", "2 Days Ago", "3 Days Ago" so on, so forth.
the first step would be calculating the date difference. for that I have given you a link. once you have that it’s just a matter of if()s to make that into a human understandable string.
__________________
please post your code wrapped in [CODE] [/CODE] tags
im sorry, i dont really understand, ive only recently started learning different methods of using sql, such as table joins, so could you possibly, if you dont mind, show me some sort of example?
let’s use a slightly off-topic date function to demonstrate
Code:
-- show all dates in european format that are not older than one week
SELECT DATE_FORMAT(mydate, GET_FORMAT(DATE, 'EUR')) FROM mytable WHERE DATE_ADD(mydate, INTERVAL 1 WEEK) > NOW();
PS. there is a function that does exactly what you want.
__________________
please post your code wrapped in [CODE] [/CODE] tags