如何使用 PHP 将泰国日期转换为英文?

目前我正在从THAITo EnglishLanguage 格式化日期,但它无法将日期格式化THAIEnglish. 我在谷歌上研究过,但在那里找不到任何东西。

以下是我的泰国约会对象

15 กรกฎาคม 2562


炎炎设计
浏览 204回答 2
2回答

一只斗牛犬

str_replace 的一种解决方案<?php$search = [&nbsp; &nbsp; // Here thai months from 1 to 6&nbsp; &nbsp; 'กรกฎาคม',&nbsp; &nbsp; // And the rest here];$replace = [&nbsp; &nbsp; // Here eng months from 1 to 6&nbsp; &nbsp; 'July',&nbsp; &nbsp; // And the rest here];$tdate = '15 กรกฎาคม 2562';$edate = str_replace($search, $replace, $tdate);var_dump($edate);

繁花不似锦

我已经解决了这个问题。下面是我的代码。$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){&nbsp; &nbsp; if($date[1] == $monthNamesThai){&nbsp; &nbsp; &nbsp; &nbsp; $testKey = $key;&nbsp; &nbsp; }}$resultDate = $date[0]." ".$monthNameEnglish[$testKey]." ".$EnglishYear;echo $resultDate;
打开App,查看更多内容
随时随地看视频慕课网APP