chris
chris

Reputation: 36937

php mysql storing just hours minutes seconds

I know a typical timestamp in any format readable or otherwise is always equivalent to a date time second day month year etc. However I want to be able to search by hours minutes seconds where the day month year are irrelevant. So I am trying to wrap my head around that ability and what would be the best method of storing time so I can create searches around that alone without m-d-y getting in my way.

Upvotes: 1

Views: 2598

Answers (2)

akirk
akirk

Reputation: 6837

Try using the TIME field type. The TIMESTAMP field type should only be used anyway when you want MySQL to update the field when updating the row.

Upvotes: 1

Amir
Amir

Reputation: 4111

$hour = date("H",$date); $minute = date("i",$date); $second = date("s",$date);

and save them on your table as hour,minute and second

Upvotes: 0

Related Questions