开发者

Check whether date is 12 hours before in PHP

开发者 https://www.devze.com 2023-03-28 17:05 出处:网络
I have a table (MySQL) data that stores a bunch of signup information. What I\'m trying to do it calculate whether a row\'s creation has been 12 hours or not.

I have a table (MySQL) data that stores a bunch of signup information.

What I'm trying to do it calculate whether a row's creation has been 12 hours or not.

For each row I have a cell called "date" which displays like this:

July 13, 2011 19:28 or August 7, 2011 03:33

I'm looking for a simple if/else statement that picks up on whether "date" h开发者_JAVA技巧as been 12 hours since its creation or not.


SELECT ...
FROM yourtable
WHERE `date` <= DATE_SUB(now(), INTERVAL 12 HOUR)

note that naming your field 'date' is bad practice. Date is a reserved word in MySQL, and reserved words should NOT be used as field names.

0

精彩评论

暂无评论...
验证码 换一张
取 消