Click here to Skip to main content
14,667,847 members
Rate this:
Please Sign up or sign in to vote.
See more:
If am using 6 dates its displaying properly , if am adding 1 more and use 7 dates , it gives the error

$mult3=mysql_fetch_array($mult1);
$date = DateTime::createFromFormat("Y-m-d", $mult3['ex_dates']);
$onee=$date->format("d").'01';
$date = DateTime::createFromFormat("Y-m-d", $mult3['ex_dates']);
$twoo=$date->format("d").'02';
$date = DateTime::createFromFormat("Y-m-d", $mult3['ex_dates']);
$three=$date->format("d").'03';



am using the same code in a different page and it works there

What I have tried:

am using the same code in a different page and it works there 
Posted
Updated 14-Sep-20 0:54am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

This would indicate that the $date variable doesn't contain a valid DateTime value. The documentation states that createFromFormat will return FALSE if the function fails, so you probably need to add a check to see whether $date is FALSE.

It might be worth checking the value of $mult3['ex_dates'] to ensure that it's not null and matches the exact format of "Y-m-d" as well.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100