将日期从荷兰转换为英文

dfg*_*te4 5 php date magento

我认为这很容易,但事实并非如此!我有个约会:2015年2月28日(荷兰),我想将其转换为英文Ymd

问题是网站是多语言的,所以我希望它保持动态(将mai替换为may)不是解决方案,我已经尝试过:

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

要么

 $date = date_parse(($value));
  print_r($date);
Run Code Online (Sandbox Code Playgroud)

但我一直都在:1970-01-01

有任何想法吗?

我正在尝试在magento中实现这一目标,所以也许对此有magento功能

Yas*_*lev 0

使用 strptime() 函数 - 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;
Run Code Online (Sandbox Code Playgroud)