Hi Tim.

One of the largest changes I faced when switching from Access to PHP/MySQL
is the loss of "official" input masks, the short time for example.  The only
way (I actually like it much better now) around this is to do all of your
data validation in PHP before you do your db querying -- rely on yourself,
not Microsoft.

One thing that unix and php affords, however, is the Unix timestamp -- the
number of seconds since the epoch, or 12:00AM January 1, 1970.  I use the
unix_timestamp as a base for all of my primary keys, dates, times, and
intervals because its integer-base provides the most functionality for
searching, formatting and sorting.  For your songs, I would recommend
storing them in the db as total seconds.  You can consequently use the
date("h:s:i",$songlength)  function to format the length for your users, and
the mktime(h,m,s) to receive input from your users and filter it into your
tables.  You can also easily add or subtract times and order your songs by
length should you need to.

A song of 6 minutes and 24 seconds:

mktime(0,6,24) = 384 seconds

date("m:i", 384) = 6:24

Check out the online manual at www.php.net for more convenient time

Also, you might want to consider looking into PostgreSQL.  Supposedly it
offers the ability to validate data by checking it against rules such as
format, min/max value, and required/notrequired fields before actually
inserted or updating a record.  As for checking short time formats with it,
I am not anyone to tell you anything.


-----Original Message-----
From: Timothy Wright [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 13, 2001 11:46 AM
To: PHP-Db List
Subject: Newbie Time Fields question

Hello all -

I have created a database in Access 97 which will soon be converted to MySQL
for web use.  It is a music catalog with tracks of each CD listed with
times.  My question is: what is the best data type for the track times
(2:37, 6:24, etc.) which will allow me to add all the tracks of a CD and
come up with a total CD time (65 minutes and 59 seconds, for example).
Right now I am using the "short time" format in Access which only allows
times up to 23:59 (I guess it's actually designed for hours/minutes) and I
haven't figured out how to add the values.  Is there a data type that will
work in Access, and/or what would be the equivalent format in MySQL??
 Also - does anyone have an example of a PHP/MySQL solution for a music

Thanks in advance,

Tim Wright

:::                                     :::
:::   Timothy Wright                    :::
:::   mailto:[EMAIL PROTECTED]   :::
:::   Digital Network Enterprises       :::
:::   http://www.01network.com          :::
:::                                     :::
:::   secure e-mail by request          :::
:::   (PGP signature and/or encryption) :::

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to