Irish SEO,  Marketing & Webmaster Discussion

 
ThinkGeek - Cool Stuff for Geeks and Technophiles

php compare date

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


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-12-2006, 07:26 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default php compare date

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 07-12-2006, 09:24 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

got it sorted.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 08-12-2006, 09:24 AM
ph3n0m's Avatar
Webmonkey
Recent Blog: I met a butterfly
 
Join Date: Jan 2006
Location: Ireland
Posts: 299
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ph3n0m will become famous soon enough
Send a message via AIM to ph3n0m Send a message via MSN to ph3n0m Send a message via Yahoo to ph3n0m Send a message via Skype™ to ph3n0m
Default

and the solution was?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 08-12-2006, 09:41 AM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 08-12-2006, 09:50 AM
ph3n0m's Avatar
Webmonkey
Recent Blog: I met a butterfly
 
Join Date: Jan 2006
Location: Ireland
Posts: 299
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ph3n0m will become famous soon enough
Send a message via AIM to ph3n0m Send a message via MSN to ph3n0m Send a message via Yahoo to ph3n0m Send a message via Skype™ to ph3n0m
Default

I normally use the default timestamp to do the comparisson and then do the convert after the fact
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
compare, date, php

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

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


All times are GMT +1. The time now is 07:27 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0