我的代码是这样的,当我们在印地语中使用date并将其保存到数据库时,它还会引发错误,并且在php中不可读,因此我们遇到了问题。我们已经通过Locale php标准功能对其进行了更改
$array = [$date1, $date2, date('Y-m-d', strtotime($date2))];
print_r($array);
Array
(
[0] => 2014-08-10
[1] => 2018-12-26
[2] => 2018-12-26
)
Array
(
[0] => 2019-01-31
[1] => 30-जनवरी-2019 //We are using hindi
[2] => 1970-01-01 //Throwing wrong data it should be 2019-01-30
)
Warning : date_diff() expects parameter 2 to be DateTimeInterface, boolean given
Notice: Trying to get property of non-object
答案 0 :(得分:0)
尝试一下:-
$ date =“30-जनजरी-2019”;
$ my_date = date('m / d / y',strtotime($ date));
回显$ my_date;
答案 1 :(得分:0)
您可以设置locale
并在date
函数中使用印地语
setlocale(LC_ALL, "hi_IN"); // locale for Hindi (India), You can reset locale as it is later
现在
$date2 = "30-जनवरी-2019";
echo date('Y-m-d', strtotime($date2));
setlocale(LC_ALL, "en_US"); // "English (United States)" you can reset after use