rufio45 Posted December 13, 2007 Share Posted December 13, 2007 Hello, this is my first post in the forums, I noticed how you guys help each other a lot so I thought maybe you could help me. I'm trying to get a website to display several divs and each is painted with different colors, I get the colors from the date in which they were insterted into the database (Ms sql server 2005), and when i try to paint the oldest record for a certain part as green and all the others as yellow, it doesnt work quite as i expected it, it's painting green all the "first" records that I input within a minute, somehow it's not comparing the dates seconds because it thinks that "2007-12-13 07:40:12" is the same as "2007-12-13 07:40:45", when it changes minutes then it works but i need it to change by the second. Here is the code if (date("Y-m-d H:i:s",strtotime($row["f1"]))==date("Y-m-d H:i:s",strtotime($row["f2"]))){ //f1 is the oldest $color=1;//color green } else{ $color=2;//color yellow } // I've tried using "U" as the format instead of "Y-m-d H:i:s" but it does the same. Quote Link to comment Share on other sites More sharing options...
rufio45 Posted December 13, 2007 Author Share Posted December 13, 2007 forgot to add, when i print (echo) the F1 or F2 dates it only shows Dec 13 2007 7:56AM (only an example), so is it not bringing the seconds from my database or what's up? Because in my database i see them, seconds and miliseconds, i'm using php 5.1.3 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 13, 2007 Share Posted December 13, 2007 Don't compare ASCII dates, just use what's being returned from the DB: <?php $color = ($row['f1'] == $row['f2'])?1:2; ?> Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.