You are here: Re: Modify MySQL time column values « All PHP « IT news, forums, messages
Re: Modify MySQL time column values

Posted by -Lost on 10/10/66 11:51

"Ridge Burner" <nospam@nospam.com> wrote in message
news:OOKdnQfSFc2OVT_ZnZ2dnUVZ_sWdnZ2d@insightbb.com...

> I think data should be stored in a column that is designed to hold that type

You are exactly right.

> I created a table with a column type of 'time'. The default format for this column is =>
> 00:00:00 (HH:MM:SS). The form I made to populate the table has the time in this format
> => 00:00 (MM:SS), without the hours explicitly specified. So when I intended to store
> something like 3:49 (3 minutes forty-nine seconds), it actually stores it as 03:49:00 (3
> hours forty-nine minutes)!

You realize TIME is not a timer-type field, right? As in, even if it stored 03:49, it is
referring to 3:49 AM, *not* 3 minutes and 49 seconds.

The only thing I can think of offhand would be for you to use an INT, with a length of 4.
*IF* you know it is always going to be 4 numbers, of course. Then, you can simply split
them in half, insert a colon and go.

Or, you could simply change the form to input the correct type (best move) and retrieve it
in whatever fashion you wish. I always use a full TIMESTAMP, and extract what I need.
PHP's date function is madly in love with TIMESTAMP for the record.

I thought of one last thing... in case you are timing something. On the start of your
script, record a TIMESTAMP value, then on completion (submit, whatever) use
TIMESTAMPDIFF() to compare your original timestamp to the current timestamp. Thereby,
timing. I am just grasping at straws at this point... hope I helped somewhat.

-Lost

 

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

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