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
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.