I would like to get a Y-m-d
formatted date from a string like "28 January 1959".
I tried date("Y-m-d", strtotime($dateString))
, but it returns 1970-01-01.
The weird thing is that, if I debug the above code with "28 January 1959" constant, it works, but if I replace the string with the variable which stores the same value, it returns 1970-01-01.
Any idea?
The solution is remove special characters from the date string:
date("Y-m-d", strtotime(preg_replace('/[^A-Za-z0-9\-]/', '', $dateString)))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments