MySQL queries for selecting records based on different time criteria using a timestamp integer field named created
.
SELECT
*
FROM
your_table
WHERE
created >= UNIX_TIMESTAMP(DATE_FORMAT(CURDATE(), '%Y-%m-%d 10:00:00'))
ORDER BY
created DESC
;
SELECT
*
FROM
your_table
WHERE
created >= UNIX_TIMESTAMP(CURDATE()) AND created < UNIX_TIMESTAMP(CURDATE() + INTERVAL 1 DAY)
ORDER BY
created DESC
;
SELECT
*
FROM
your_table
WHERE
created >= UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 1 DAY)) AND created < UNIX_TIMESTAMP(CURDATE())
;
SELECT
*
FROM
your_table
WHERE
created >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 31 DAY))
;
SELECT
*
FROM
your_table
WHERE
created >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 60 DAY))
;