[thelist] comparing a TIMESTAMP(6) entry in mysql to today's date

Dunstan Orchard dunstan at 1976design.com
Fri Sep 13 07:03:00 CDT 2002


Hi there,

I'm sure this is dead simple, but I'm stuck.

I have an entry in a mysql db called 'date_posted'. I am grabbing it in php
like this:

$date_posted = mysql_result($result, $i,"date_posted");

It's a TIMESTAMP(6) column, so the date returned is in the 020907 format (for
7th of September 2002).


I want to take that date, compare it to today's date (which php can generate)
and work out if the difference is less than/equal to 30 days, or greater than
30 days.

(If the item was posted less than 30 days ago I'm going to put a 'new' image
next to it, if it's older than 30 days then I won't.)


Any help would be greatly appreciated.
(could you cc me please)

Thanks - dunstan

---------------------------
Dorset, England
http://www.1976design.com/
http://www.orchard.it/
http://www.maccaws.org/



More information about the thelist mailing list