<?php
class Tool{
function toKhNum($number) {
$khNum = ['0'=>'០', '1'=>'១', '2'=>'២', '3'=>'៣', '4'=>'៤', '5'=>'៥', '6'=>'៦', '7'=>'៧', '8'=>'៨', '9'=>'៩'];
$stringNum = strval($number);
$khString = '';
$chars = str_split($stringNum);
foreach ($chars as $char ){
$khString .= $khNum[$char];
}
return $khString;
}
function getKhDate($rawDate){
$KhmerDays = ['ច័ន្ទ', 'អង្គារ', 'ពុធ', 'ព្រហស្បតិ៍', 'សុក្រ', 'សៅរ៍', 'អាទិត្យ'];
$KhmerMonths = ['មករា', 'កុម្ភៈ', 'មិនា', 'មេសា', 'ឧសភា', 'មិថុនា', 'កក្កដា', 'សីហា', 'កញ្ញា', 'តុលា', 'វិច្ឆិកា', 'ធ្នូ'];
$month = date('m', strtotime($rawDate));
$day = date("N", strtotime((date('l',strtotime($rawDate)))));
$daym = $this->toKhNum(date('d', strtotime($rawDate)));
$year = $this->toKhNum(date('Y', strtotime($rawDate)));
return ('ថ្ងៃ '.$KhmerDays[$day-1].' ទី '.$daym.' '.$KhmerMonths[$month-1].' '.$year);
}
}
<?php
// GET HTTP REQUEST
$app->get('/', function($req, $res) {
require __DIR__.'/../tool.php';
$_tool = new Tool();
date_default_timezone_set("Asia/Phnom_Penh");
$date = $_tool->getKhDate(date('Y/m/d'));
$data = ['title'=>'ទំព័រដើម', 'date'=>$date];
$res->render('home', $data);
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title> <?php echo $appName." / ".$title; ?></title>
<script src="public/scripts/jQuery.js"></script>
<link href="public/fonts/setup.css" rel="stylesheet" ></link>
<link href="public/images/site_logo.png" rel="icon" ></link>
<link href="public/styles/global.css" rel="stylesheet"></link>
<link href="public/styles/partials/header.css" rel="stylesheet"></link>
</head>
<body>
<section class='Header'>
<div class='wrapper region'>
<div class='datetime'>
<div class='date'><?php echo $date ?></div>
<div class='time' id='kh-clock'>ពេលម៉ោង</div>
</div>
<div class='title'>
<a href="./"><?php echo $appName ?></a>
<div class='description'>ព័ត៌មាន ចំណេះដឹង វប្បធម៌ កំសាន្ត</div>
</div>
<form class='search'>
<input type='text' name='q' placeholder='Search' />
<input type='submit' value='ស្វែងរក' />
</form>
</div>
</section>
<script src='public/scripts/partials/header.js'></script>
<?php require('menu.php') ?>
<div class='site region'>
Epizy: http://khmerweb.epizy.com