Connecting Tech Pros Worldwide Help | Site Map

Php Date conversion

Member
 
Join Date: Oct 2007
Posts: 103
#1: Jan 31 '09
I have dates stored in the format MONYY eg. MAR08

I want to COMPARE this dates to the format (YYYY-MM-DD) EG.2009-01-
01



Kindly Help

Thanks
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,746
#2: Jan 31 '09

re: Php Date conversion


Hi.

How are you storing these dates?
If they are being stored in any decent database system, you would most likely be far better of using that system's date type. Like the DATE type, found in pretty much all SQL servers.

In any case, you would have to convert either format to match the other, or simply extract the year and month from both and compare them.

The substr function should help you there.
Member
 
Join Date: Oct 2007
Posts: 103
#3: Jan 31 '09

re: Php Date conversion


I Want to check if the date which is stored as MONYY in the database is less then 2008-03-31
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,746
#4: Feb 1 '09

re: Php Date conversion


Quote:

Originally Posted by SSG001 View Post

I Want to check if the date which is stored as MONYY in the database is less then 2008-03-31

Yes, and like I said in my previous post, to do that you will have to extract the month and year parts and convert them into a format that you can compare.

If your having trouble doing that, show us what you have tried, and we might be able to point out what the problem is.
Reply


Similar PHP bytes