I have a string representing a date: 21 marzo 2017
. I want to convert it to a Unix timestamp.
echo strtotime('21 march 2017');
works because the month is in English.echo strtotime('21 maggio 2017');
doesn't work because the month is in Italian.How can I get a Unix timestamp from that Italian string?
You should first convert your months in english with str_replace
:
str_replace('marzo','march',"21 marzo 2017");
Then you can use echo strtotime('21 march 2017');
If you have to convert other date, consider using a function and a switch-case.