You are here: Re: Date storage format « PHP Programming Language « IT news, forums, messages
Re: Date storage format

Posted by Rik Wasmus on 01/01/08 14:27

On Tue, 01 Jan 2008 15:22:19 +0100, Serious_Practitioner
<Serious_PractitionerNOSPAM@att.net> wrote:
> Good day, and Happy New Year!

The same to you.

> I'm trying to teach myself some PHP and MySQL and the project that I've
> decided to build will be dependent on queries involving comparisons of
> dates. I'd like some advice, please, on whether I should -
>
> 1. Store the date (2008-01-01) in the MySQL table as a date and compare
> to
> that, or...
> 2. Create a/ timestamp/s for the date/s in question, store the timestamp
> and
> then compare to that.
>
> If the timestamp is the way to go, should that column be of type
> "Timestamp"
> or will that cause the string to be altered to a MySQL timestamp?

If you plan to base a lot of queries on date lookups/comparisons, go for
the native date format in MySQL. Any formatting of a date-output can be
done with MySQL itself. Should you need a timestamp for some reason in the
PHP code itself (be very sure you need this... MySQL might be more capable
then you think), you can always query the timestamp using UNIX_TIMESTAMP()
on the column.

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
--
Rik Wasmus

 

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

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