bsamson Posted November 6, 2008 Share Posted November 6, 2008 I have a table that looks like this: ID entryDate storeNo 01 1225843575 5843 02 1225929544 5843 entrydate 1225843575 is 11/04/2008, and 1225929544 is 11/05/2008. Now, when I run this query: SELECT * FROM v2breakdown WHERE DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%m/%d/%Y') = '11/05/2008' phpMyAdmin returns both id 01, and id 02. Is there something wrong w/ the query? It should only return ID 02. Thanks in advance for any direction! Thanks! Link to comment https://forums.phpfreaks.com/topic/131576-solved-strange-results-from-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 6, 2008 Share Posted November 6, 2008 Execute the following two queries and tell us what you get - SELECT FROM_UNIXTIME(1225843575) SELECT FROM_UNIXTIME(1225929544) Link to comment https://forums.phpfreaks.com/topic/131576-solved-strange-results-from-query/#findComment-683391 Share on other sites More sharing options...
bsamson Posted November 6, 2008 Author Share Posted November 6, 2008 SELECT FROM_UNIXTIME(1225843575) = 2008-11-05 00:06:15 SELECT FROM_UNIXTIME(1225929544) = 2008-11-05 23:59:04 hhmmm ... im confused now. because in php if i run: echo date("m/d/Y", 1225843575)."<br>".date("m/d/Y", 1225929544) I get: 11/04/2008 11/05/2008 Link to comment https://forums.phpfreaks.com/topic/131576-solved-strange-results-from-query/#findComment-683392 Share on other sites More sharing options...
PFMaBiSmAd Posted November 6, 2008 Share Posted November 6, 2008 The timezone setting of mysql is different than your php. A Unix Timestamp has several problems and limitations with its use. If you use a mysql DATE or DATETIME, 2008-11-05 will always be 2008-11-05. It won't care what the server's clock is or what timezone setting is being used to convert a Unix Timestamp into a date/time value. Link to comment https://forums.phpfreaks.com/topic/131576-solved-strange-results-from-query/#findComment-683394 Share on other sites More sharing options...
bsamson Posted November 6, 2008 Author Share Posted November 6, 2008 Great! Thanks for your help. It's a new dedicated server and the timezone was incorrect initially. When I set it correctly it did not update mysql. After restarting MySQL all was well. Thanks again! Link to comment https://forums.phpfreaks.com/topic/131576-solved-strange-results-from-query/#findComment-683650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.