0

I'm trying to create new date in PHP but it always returns false no matter what I try. What returns false:

date_create($request->start_date);
DateTime::createFromFormat('d/M/Y H:i:s', $request->start_date);
date_create_from_format("d/M/Y H:i:s",$request->start_date);

and $request->start_date looks like this "25/04/2017 20:30:00"

1 Answer 1

4

Try

DateTime::createFromFormat('d/m/Y H:i:s', $request->start_date);

The M you were using is for a textual representation of a month, not numeric (see manual)

Sign up to request clarification or add additional context in comments.

1 Comment

yeah that fixed it. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.