0

I have a site that people join and enter their birthdate which I want to store in MySQL as a date Type.

The data I have is

Day - eg: 1 or 11, 23 etc
Month - eg: March or April or December
Year - eg: 1975 or 1964 or 1944 etc

thus eg: 3 March 1966

How can I convert this into a format that can be saved into as a MySQL date type?

thankyou

2 Answers 2

1
$datetime = DateTime::createFromFormat('j F Y', '3 March 1966');
echo $datetime->format('Y-m-d');

See it in action

Reference:

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

Comments

0

it can be created using date() and strtotime() functions

 $mysql_date= date("Y-m-d",strtotime("3 March 1996"));

working demo

Comments

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.