April 2, 2012

Match 2 dates in php

Question by user1307519

I need to match a date from database which is in format e.g 2012-04-12 with month e.g January using php can any one please help
It`s ok if there is any alternate answer
Pl help……..

Answer by Starx

Quite a horrible question, but I will guess the problem.

To retrieve the month from the database

$date = $row['date']; //example of retrieving data row
$month =  date("M",strtotime($date)); // retrieving the month of the date


//Now match them

if($month == "January") {
  //do something
}

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!