If you dont understood difference in between m-d-Y and d-m-Y format. We try to simplify the conversion process while taking a string value from input field, convert this to timestamp and again make this format suitable to mysql insertion which is (Y-m-d H:i:s)
While inserting a date of birth 7th March 1990
if we type 07-03-1990. What do you think PHP will take this as ( d-m-Y ) or ( m-d-Y ) ?
INPUT -> timestamp -> Y-m-d H:i:s -> insert into database
Once its converted to timestamp there is no error converting to any date format. Most difficult situation to understand while you input a string and we need this t convert into date considering date at first place or month at first place.
So strtotime($dateformat) accepts only datetime formats which says
* Date values separated by slash are assumed to be in American order: m/d/y
* Date values separated by dash are assumed to be in European order: d-m-y
So if you will be using ‘/’ strtotime function will be automatically consider month at first position then date.
and if you will be using ‘-‘ strtotime will consider date at first postion then month,
date(‘Y-m-d’, strtotime(’07-03-1990′)); /* 7 MARCH 1990 */
date(‘Y-m-d’, strtotime(’07/03/1990′)); /* 3 JULY 1990 */
date(‘Y-m-d’, strtotime(’03-07-1990′)); /* 3 JULY 1990 */
date(‘Y-m-d’, strtotime(’03/07/1990′)); /* 7 MARCH 1990 */