Re: Date Handling Recommendations

From: Date: Thu, 21 Jul 2005 22:45:34 +0000
Subject: Re: Date Handling Recommendations
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-219162@lists.php.net to get a copy of this message
Jim Moseby wrote:
Hi all, I need to manage some records with dates. mmddyyyy I'm putting select options breaking the three up in numeric pull
[snip]
For instance, what would you have to do to get the day of the week for a day 66 days prior to the stored date? If your date was stored in a DATE field, all you would have to do is: $result=mysql_query("SELECT DATE_FORMAT(DATE_SUB(stored_date, interval 66 days) ,"%W") from tablename where..."); $row=mysql_fetch_row($result); echo "The day if the week is ".$row[0]; ...if your dates are stored in integer fields, how would you easily come about a similar result? JM
Um... Just because... $dayOfTheWeek = date("l", $dateFromDatabase - (66 * 86400)); *assuming by integer fields the OP is talking about unix timestamps* But you, and a previous poster, do bring up an interesting idea about this. I'd never thought about just how many different things you can do, or might need to do, with a DATE field in the database. Thanks!

« previous php.general (#219162) next »