I dont know if this question already asked before.
Actually i have two date:
$date1 = $DATABASE_VALUE;
$day1 = date('d', strtotime($date1)); // $date1 is my database value
$date2 = date('Y-m-d H:m:s');
$day2 = date('d', strtotime($date2)); // $date2 current date
and I need to Check this:
if($day1 <= $day2) {
...
}
It is working if $date1
has a date value (Like - 2014-06-12 10:20:50
) and i have set a default value which is
0000-00-00 00:00:00
so when $date1
is not 0000-00-00 00:00:00
(could be 2014-06-12 10:20:50
) then :
$date1 = "2014-06-12 10:20:50"; // database value
$day1 = date('d', strtotime($date1));
echo $day1; // returns 12 (which is correct)
But if $date1
is 0000-00-00 00:00:00
then
$day1 returns 01
WHY?
If its a behavior of strtotime()
(Not Sure About That).
Then tell me What should i do if date comes 0000-00-00 00:00:00
?
Please help..