目前,我正在做从THAI
到English
语言的日期格式,但它不能格式化从THAI
到English
的日期。我在Google上做了研究,但在那里找不到任何东西。
以下是我的泰国日期表格
15 กรกฎาคม 2562
发布于 2019-07-30 13:40:20
一种使用替换的解决方案
<?php
$search = [
// Here thai months from 1 to 6
'กรกฎาคม',
// And the rest here
];
$replace = [
// Here eng months from 1 to 6
'July',
// And the rest here
];
$tdate = '15 กรกฎาคม 2562';
$edate = str_replace($search, $replace, $tdate);
var_dump($edate);
发布于 2019-07-30 15:48:08
谢谢你们。我已经解决了这个问题。下面是我的密码。
$date = explode(" " , "15 กรกฎาคม 2562");
$EnglishYear = $date[2] - 543;
$testKey = '';
$monthNamesThai = array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน",
"กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม");
$monthNameEnglish = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
foreach($monthNamesThai as $key => $monthNamesThai){
if($date[1] == $monthNamesThai){
$testKey = $key;
}
}
$resultDate = $date[0]." ".$monthNameEnglish[$testKey]." ".$EnglishYear;
echo $resultDate;
https://stackoverflow.com/questions/57272881
复制相似问题