0

I have a german date format, that looks like this:

Montag, 21. Dezember 2015

Now I want to convert this string to a unix timestamp. I tried to use:

date_parse_from_format("l, d. F Y", "Montag, 21. Dezember 2015");

But there are two problems:

  1. The german month isn't accepted, so I created an array containing every german and english month, so I only have to replace it.

    [year] => 2015 [month] => [day] => 21

  2. The result of the function returns the timestamp in the current timezone. Stupid Workaround: simply adding 10800.

So is there a good solution to get the right timestamp?

ForJ9
  • 735
  • 8
  • 24
  • 1) Do: `$neTime = str_replace(array_merge($germanDays, $germanMonths), array_merge($englishDays, $englishMonths), $oldTime);` 2) Take a look at: http://php.net/manual/en/datetime.settimezone.php – Rizier123 Dec 18 '15 at 23:03
  • [IntlDateFormatter](http://php.net/manual/de/class.intldateformatter.php) might be worth taking a look at, [IntlDateFormater::parse](http://php.net/manual/de/intldateformatter.parse.php) more precisely. – ccKep Dec 18 '15 at 23:05
  • Does `strtotime()` not work? – grimmdude Dec 18 '15 at 23:05
  • Use `date_default_timezone_set()` to change the timezone. – Barmar Dec 18 '15 at 23:25

0 Answers0