This is a discussion on php compare date within the Coding Help forums, part of the Webmaster Help category; 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 ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||||
| 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.
__________________ :. Web Design & Development Web Design Ireland :. Search Engines Optimization Search Engines Optimization :. Directory Submission Directory Submission :. News & Press Release Ireland GiveItSocks.com :. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories :. I Have 2 Find It Directory SEF Directory |
| |||||
| got it sorted. |
| |||||
| and the solution was? |
| |||||
| 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. |
| |||||
| I normally use the default timestamp to do the comparisson and then do the convert after the fact |
| Tags |
| compare, date, php |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calender script (php, mysql) | 7aken | Coding Help | 3 | 20-10-2006 06:57 AM |
| php, mysql & .asp from same laptop | alex | Server / Technical Administration Tips and Queries | 11 | 16-10-2006 06:01 PM |
| Do Php Accelerators Make Any Difference? | blacknight | Coding Help | 2 | 13-09-2006 11:28 PM |
| Ioncube encoded PHP Scripts | georgiecasey | Coding Help | 3 | 29-08-2006 11:49 AM |
| PHP on windows | louie | Coding Help | 20 | 22-02-2006 05:25 PM |