You are here: Re: Data format in application or database? « PHP Programming Language « IT news, forums, messages
Re: Data format in application or database?

Posted by larry on 09/09/06 17:25

turnitup wrote:
> I have found that by far the easiest way to store dates in my LAMP
> application is in a text string in the database in Unixtime format.
>
> First of all, what would be the most efficient data type to store this as?
>
> Secondly, in terms of translating into a human readable format, is it
> quicker to format the date in the application using date() or in the
> database in the select query?
>
> Any thoughts?

Unless you are doing something that involves 'real-time' (as in in
relatrion to events like logging data) the Unix time stamp to me seems
to be a pain, as most of my work resolves down to the day, or in
general time of day (down to the minute). Also because of daylight
savings is factored in you may run into unexpected problems in date
calculations.

I have written up functions to convert to/from an 8 digit interger for
date recording: YYYYMMDD which as been used on earlier development
environments (like FoxBase), It does not suffer from 'when's the epoch'
or running out of seconds in 2038. That format is easy to sort by and
you can use PHP to convert it into a timestamp value if you want to do
math on it.

For time I also use an interger representing number of minutes since
midnight (1440 in a 24hour period), though not human readable it is
math friendly.

This is my preference, my reasonong is to make it generic so data can
cross between systems, but human readable enough if there is no machine
involved. Your mileage will vary on who you ask. Stick with what
works for you,

Larry

 

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

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