Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you select records with a certain time range from MySQL using PHP?

Tags:

sql

php

mysql

How to choose from MySQL, using PHP, records that were created for a certain period of time, if each record has creation time in timestamp?

like image 403
NiLL Avatar asked Dec 04 '22 08:12

NiLL


1 Answers

You do a query similar to:

SELECT *
FROM table
WHERE creation_time BETWEEN '2011-01-01 00:00:00' AND '2011-03-01 00:00:00'

Here it'll select all entries that have a creation time between January 1st, 2011 and March 1st, 2011.

like image 160
Sebastian Paaske Tørholm Avatar answered Dec 11 '22 16:12

Sebastian Paaske Tørholm