You are here: Re: [PHP] Date Handling Recommendations « PHP « IT news, forums, messages
Re: [PHP] Date Handling Recommendations

Posted by Edward Vermillion on 07/22/05 01:45

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!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация