Gayan
Gayan

Reputation: 2935

PHP MYSQL, How to compare same date two timestamp

Using PHP time() function, I have got this timestamp - 1407760251 (11-08-2014)

Also using only YY-MM-DD (date picker) I have generated this timestamp - 1407708000 (11-08-2014)

MySQL table has time() timestamp, I want to filter same day records from MYSQL table how to do it? please help me.. thank you

Upvotes: 0

Views: 489

Answers (1)

Ende Neu
Ende Neu

Reputation: 15773

Use date for the PHP side:

date("d-m-Y", $millis);

and use DATE on the MySQL side to make a timestamp comparable to the date you have:

SELECT someFields
FROM MyTable
WHERE DATE(myDate) = date("d-m-Y", $millis)

Upvotes: 1

Related Questions