Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
06-05-2007, 08:28 AM #1
- Join Date
- Aug 2006
- Thanked 0 Times in 0 Posts
comparing the today's date with timestamp value
i have a mysql table which has 3 fields
1.id 2.username 3.time
1 abcd 1181027044
i want to fetch only those user id's and usernames whos time is equal to current date.any of your idea will be surely appreciated.
06-05-2007, 01:51 PM #2
- Join Date
- May 2007
- Manchester, UK
- Thanked 2 Times in 2 Posts
SELECT `id`, `username` FROM `tablename` WHERE `time`=TIMESTAMP(NOW());
I'm not sure if you need NOW() in there or not. But this will only select for values down to the second. Perhaps you want this to display users who just signed up today, in which case;
SELECT `id`, `username` FROM `tablename` WHERE DATE(FROM_UNIXTIME(`time`)) = DATE(NOW());
Again, not sure about the need for the NOW(). Actually I'm not 100% sure about the SQL in general, perhaps someone with more SQL experience would like to correct or optimize my suggestion.
Every PHP programmer of any skill level should set error_reporting(E_ALL); at the top of their scripts or in their php.ini