Jump to content

PHP not comparing dates?


rufio45

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/81503-php-not-comparing-dates/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.