- Demo : ketsathalan
<!DOCTYPE html>
$thoigian = $value["thoigian"]; ("2026-07-31 14:41:39")
$timestamp = strtotime($thoigian);
$days = array(
'Sunday' => 'Chủ nhật',
'Monday' => 'Thứ Hai',
'Tuesday' => 'Thứ Ba',
'Wednesday' => 'Thứ Tư',
'Thursday' => 'Thứ Năm',
'Friday' => 'Thứ Sáu',
'Saturday' => 'Thứ Bảy'
);
$day = $days[date('l', $timestamp)];
<div class="pdnews-times">
<span><img src="/themes/'.$ThemeSel.'/images/icon-blog2.png"> '.$day.',</span>
<span class="news_home_content_short_time">
'.date('d/m/Y', $timestamp).'
</span>
</div>
** HTML
<div id="printArea">
<div class="no-print">Nội dung left</div>
<div class="content-right">Nội dung phải</div>
<!--Nội dung phải được in ra-->
</div>
** CSS
<style type="text/css">
@media print{
.certificate-container{
margin:0 !important;
padding:8mm !important;
height:auto !important;
min-height:auto !important;
}
.certificate-inner-border{
padding:6mm !important;
}
p,h1,h2,h3,h4,h5,h6{
margin-top:2px !important;
margin-bottom:2px !important;
}
.no-print{
display:none!important;
}
body *{
visibility:hidden;
}
#printArea,
#printArea *{
visibility:visible;
}
#printArea{
position:absolute;
left:0;
top:0;
width:100%;
}
}
</style>
** JS
<script type="text/javascript">
function printDiv(){
window.print();
}
</script>
** HTML
<input type='text' name='currency' id='currency' class='form-control'>
Nhập 25500 -> thành 25.500
** PHP
Code php lấy lại giá trị: 25500
$currency = str_replace('.', '', $_POST['currency']);
** JS
<script type="text/javascript">
$("#currency").on("input", function () {
// Chỉ giữ lại số
let value = $(this).val().replace(/\D/g, "");
// Format 25.500
if (value !== "") {
value = Number(value).toLocaleString("vi-VN");
}
$(this).val(value);
});
</script>
##┌────────────────────────────────────────────────┐
## Implode
##└────────────────────────────────────────────────┘
function ConvertImplode($post){
if(empty($post) || !is_array($post)){
return '';
}
$post = array_map('trim', $post);
$post = array_filter($post);
return implode('**', $post);
}
$maymoc1 = ConvertImplode($_POST['maymoc1']);
$maymoc2 = ConvertImplode($_POST['maymoc2']);
$maymoc3 = ConvertImplode($_POST['maymoc3']);
$maymoc4 = ConvertImplode($_POST['maymoc4']);
##┌────────────────────────────────────────────────┐
## upload-image
##└────────────────────────────────────────────────┘
function uploadVerifiedImage($file, $path){
if (!isset($file['tmp_name']) || $file['error'] != 0) {
return '';
}
$ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
$allow = array('jpg','jpeg','png','gif','webp');
if (!in_array($ext, $allow)) {
return '';
}
$filename = time().'_'.mt_rand(1000,9999).'.'.$ext;
if (move_uploaded_file($file['tmp_name'], $path.$filename)) {
return $filename;
}
return '';
}
$path = "uploads/verified/";
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$gate_image = uploadVerifiedImage($_FILES['gate_image'], $path);
$production_image = uploadVerifiedImage($_FILES['production_image'], $path);
$machinery_image = uploadVerifiedImage($_FILES['machinery_image'], $path);
$certificate_file = uploadVerifiedImage($_FILES['certificate_file'], $path);
$video_file = uploadVerifiedImage($_FILES['video_file'], $path);
if($gate_image != ''){
$input_data['gate_image'] = $gate_image;
}
if($production_image != ''){
$input_data['production_image'] = $production_image;
}
if($machinery_image != ''){
$input_data['machinery_image'] = $machinery_image;
}
if($certificate_file != ''){
$input_data['certificate_file'] = $certificate_file;
}
if($video_file != ''){
$input_data['video_file'] = $video_file;
}
##┌────────────────────────────────────────────────┐
## Note: RESULT
##└────────────────────────────────────────────────┘
$input_data = array(
'bangke1' => $bangke1,
'bangke2' => $bangke2,
);
$xsql = "SELECT id FROM api_Vfactory WHERE shopid=".$shopid;
$rs = $db->sql_query($xsql);
if($db->sql_numrows($rs)){
// UPDATE
$sql = "UPDATE api_Vfactory SET "
.$db->sql_build_array('UPDATE', $input_data)
." WHERE shopid=".$shopid;
}else{
// INSERT
$input_data['shopid'] = $shopid;
$input_data['created_at'] = time();
$sql = "INSERT INTO api_Vfactory "
.$db->sql_build_array('INSERT', $input_data);
}
##┌────────────────────────────────────────────────┐
## Note: explode
##└────────────────────────────────────────────────┘
function parseData($value){
return !empty($value) ? explode('**', $value) : array();
}
$data = data__Vfactory($shopid);
extract($data[0]);
$bangke1 = parseData($bangke1);
$bangke2 = parseData($bangke2);
foreach ($bangke1 as $key => $value) {
<tr>
<td>'.$value.'</td>
<td>'.$bangke2[$key].'</td>
</tr>
}