Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900