php compare date

Status
Not open for further replies.

louie

New Member
Something very weird happens when trying to compare date from database to date("d/m/Y")

if I have
01/11/2006 <= 06/12/2006 it works grand but if I have in the database

29/11/2006 <= 06/12/2006 it doesn't

I tried strtotime conversion but the same thing happens.
 

louie

New Member
It's more complicated to explain but I'll give it a try.
The date in the database is stored as Y-m-d H:i:s
on getting the data I was converting the date/time to IRL format (UK), then try to compare it against now() (also formated for UK).
Using echo or print they both looked fine and it would work OK if the end date wasn't 2007 (as year) and > 20 (as day). weird alright.

After more thinking and couldn't find a proper solution I resumed at not formatting the date/time, just leave it as it was (US format).
Based on that used strtotime (used in the above example as well) function to convert it to timestamp and compare then. It works, but I still can not understand why the other way around wouldn't.

I'll be honest working with date/time it's a lot easier in ASP than PHP.
 

ph3n0m

New Member
I normally use the default timestamp to do the comparisson and then do the convert after the fact
 
Status
Not open for further replies.
Top