Convert dates from Dutch to English

I thought it would be pretty easy, but it is not! I have a date: mei 28, 2015 (Dutch) and I would like to translate it into English Ymd

The problem is that the site is multilingual, so I would like it to remain dynamic (replace May with May), this is not a solution, I already tried:

setlocale(LC_TIME, 'NL_nl');
setlocale(LC_ALL, 'nl_NL'); 
echo strftime("%Y-%m-%d", strtotime($value));

or

 $date = date_parse(($value));
  print_r($date);

but all the time I get: 1970-01-01

any ideas?

I am trying to achieve this in magento, so maybe there is a magento function for this

+4
source share
1 answer

Use the strptime () function - http://php.net/manual/en/function.strptime.php

$value = 'mei 28, 2015';
$format = '%B %d, %Y';
setlocale(LC_TIME, 'NL_nl');    
setlocale(LC_ALL, 'nl_NL');

// get the array with date details 
$result = strptime($value, $format);
$day = str_pad($result['tm_mday'] + 1, 2, '0', STR_PAD_LEFT);
$month = str_pad($result['tm_mon'] + 1, 2, '0', STR_PAD_LEFT);
$year = $result['tm_year'] + 1900;

print $year.'-'.$month.'-'.$day;
0
source

All Articles