Re: date
| From: | Joel Colombo | Date: | Wed, 24 Jul 2002 22:34:28 +0000 |
| Subject: | Re: date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109369@lists.php.net to get a copy of this message | ||
i use seconds in place of time alot.
using the PHP time() function and Date() functions u can do a lot.
instead of a time / date TIMESTAMP field type i use an INT type
i then call the $the_time = Time(); and insert that.
then u can manipulate the hell outta that INT value from the DB with php's
Date() function.
allows u to compare lengths between times and perform much simplier numeric
math on the values
rather then the 'calender' math. somethings can be trickier like Leaps and
stuff, but i found more pors for most of my application needs.
Same data sizes : INT or TIMESTAMP in mysql are 4 bytes
and they both give u down to the second.
then to find out today, u just run Date('m-d-Y');
compare those vals to Date('m-d-Y', $DB_VALUE);
there u go.... it is today or it isnt ! out put data accordingly.
Joel
"Alexander Ross" <alexross@bleen.net> wrote in message
news:20020724203928.45708.qmail@pb1.pair.com...
> I have a column in one of my mysql tables which holds the date & time that
> the record was inserted. When I run a query later on I want to display
the
> date, but if the date is today or yesterday I want to display "today" or
> "yesterday" instead .. how do i compare to stored date with todays date?
> todays date -1? Thanks
>
>