We often use timestamps in databases. In fact people often use it to make session keys. Comparing timestamp is also often required when detecting any change in database. That’s too much often. 😛
table1( id (int) jointime(timestamp))
SELECT id FROM table1 WHERE jointime > '2011-10-08 00:00:00';
- This query selects id from table where jointime is greater than 2011-10-08.
- Timestamp is a standard data type in MySQL and it should have both date and time.
- For current time use NOW()
- If you are using only date then use conversion from date to timestamp using TIMESTAMP()
- With PHP
- First get the time if current time use time(), it will give time in Unix Epoch.
- Convert above time to timestamp using date() and then use in query.
- If using some other time use mktime().
- Remember the quotes they are important.