如何将另一种语言日期格式转换为英语语言格式 (Y-m-d)?

How do I convert another language date format to English language format (Y-m-d)?

我正在抓取一个博客网站,到现在为止一切正常,但现在博客网站已更改为多语言,现在我在抓取日期和时间时遇到了问题。所以帮我解决这个问题。

之前我曾经通过以下不同的方式从博客站点获取日期格式。

Thursday, 31 October 2019
Thursday, September 10, 2020

这对我来说效果很好,因为我可以通过以下方式转换为 PHP。

$fetched_date = $info['date']; // which is 'Thursday, 31 October 2019'
$time_stamp = strtotime($fetched_date);

$new_date = date('Y-m-d', $time_stamp); 
// It was gave me this date '2019-10-31',
// which is perfect for me, because i can store it to my DB.

但由于博客网站已更改为多语言,我偶尔会得到一个另一种语言的日期,如下所示。那么如何转换呢?

गुरुवार, १८ जून, २०२० // mr_IN
ગુરુવાર, 10 સપ્ટેમ્બર, 2020 // gu_IN

所以当我尝试使用这种日期格式时,它给了我错误的日期,我什至无法使用。喜欢,

$fetched_date = $info['date']; // which is 'गुरुवार, १८ जून, २०२०'
$time_stamp = strtotime($fetched_date);

$new_date = date('Y-m-d', $time_stamp); 
// It was gave me this date '1970-01-01', which is wrong and i can't store to my DB.
// it should be "2020-06-18"

当我进行抓取时,我还会得到一个语言代码,例如:mr_INgu_IN,那么如何使用该语言代码获取正确的日期呢? 我想将 PHP 中的日期转换并存储在 MySQL 中,我该怎么做?

IntlDateFormatter class 在这里可以提供帮助。但是,日期格式必须适合。

$dateString = 'गुरुवार, १८ जून, २०२०';

$timeZone = new DateTimeZone("UTC");
$fmt = new IntlDateFormatter(
    'mr_IN',
    IntlDateFormatter::FULL,
    IntlDateFormatter::NONE,
    $timeZone,
    IntlDateFormatter::GREGORIAN
);

$ts = $fmt->parse($dateString);
$dateTime = date_create("today",$timeZone)->setTimeStamp($ts);

echo $dateTime->format("Y-m-d");  //2020-06-18