JSFiddle - React, Tailwind, and code Playground

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/cultures/wijmo.culture.th.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>

JavaScript

function convertToThaiBuddhist(gregorianDate) {
    // Get the year, month, and day from the input date
    const year = gregorianDate.getFullYear();
    const month = gregorianDate.getMonth() + 1; // Months are zero-indexed in JS
    const day = gregorianDate.getDate();

    // Calculate the Buddhist Era (BE) year
    const thaiYear = year + 543;

    // Convert the month to the Thai Buddhist calendar
    const thaiMonths = [
        'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน',
        'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
    ];
    const thaiMonth = thaiMonths[month - 1];

    // Get the time in the Thai Buddhist format
    const thaiTime = gregorianDate.toLocaleTimeString('th-TH', { hour12: true });

    // Get the day of the week in the Thai Buddhist format
    const thaiDays = [
        'วันอาทิตย์', 'วันจันทร์', 'วันอังคาร', 'วันพุธ', 'วันพฤหัสบดี',
        'วันศุกร์', 'วันเสาร์'
    ];
    const thaiDayOfWeek = thaiDays[gregorianDate.getDay()];

    // Return the converted date and time
    return {
        thaiDayOfWeek: thaiDayOfWeek,
        thaiDay: day,
        thaiMonth: thaiMonth,
        thaiYear: thaiYear,
        thaiTime: thaiTime
    };
}

// Test the function
const gregorianDate = new Date(2024, 2, 17); // March 1, 2024
const thaiDate = convertToThaiBuddhist(gregorianDate);
console.log(thaiDate);