Jessie Stalk
Jessie Stalk

Reputation: 991

Selecting all timestamps for a certain date in PHP

I have a table with a few records and for each of these records I've also added a UNIX_TIMESTAMP. Now, I also have a search engine for those records in which I can choose a date using a jQuery datapicker. My question is how do I make the request so that to select all timestamps from the database for a certain date.

Upvotes: 0

Views: 54

Answers (3)

codinglazy
codinglazy

Reputation: 13

use unix timestamp you can also see this

Upvotes: 0

Arth
Arth

Reputation: 13110

With an index on your timestamp column you will get a faster result with:

SELECT *
  FROM table_name
 WHERE time_stamp_column_name >= :date_picked
   AND time_stamp_column_name <  :date_picked + INTERVAL 1 DAY

Where :date_picked is your bound-in picked date as a string in the format 'YYYY-MM-DD'.

Upvotes: 2

M Khalid Junaid
M Khalid Junaid

Reputation: 64496

You can use from_unixtime to convert it into a date

select *
from 
  table
where
date(from_unixtime(your_timestamp_col)) = '2014-10-01'

Upvotes: 1

Related Questions