$start = new DateTime(21/12/2020);
while executing this statement, it gives following error: Type: Exception
Message: DateTime::__construct(): Failed to parse time string (21/12/2020) at position 0 (2): Unexpected character
What could be the reason for this error and what is the solution for it?
Advertisement
Answer
Try to replace slashes with dots or slash slashed (like 21/12/2020). Better don’t use slashes in that context.