Yêu cầu Aug 19th, 2022 2:27 p.m. 184 0 2
  • 184 0 2
0

Xứ Lý Ngày Tháng PHP tiếng anh sang việt

Chia sẻ
  • 184 0 2

em có code như sau

$nextTimeF = date("D g:i A", strtotime($nextTime));

Output : "nextF": "Fri 9:45 PM",

Em muốn xử lý cái date D ( Fri ) thành tiếng việt tự động theo kiểu

replace array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")

thành array("Thứ 2", "Thứ 3", "Thứ 4", "Thứ 5", "Thứ 6", "Thứ 7", "CN")

cảm ơn ạ

2 CÂU TRẢ LỜI


Đã trả lời Aug 22nd, 2022 1:49 a.m.
0
$nextTimeF = date("g:i A", strtotime($nextTime));
$dayOfWeek = date("w", strtotime($nextTime));
$weekday = [ "CN", "Thứ 2", "Thứ 3", "Thứ 4", "Thứ 5", "Thứ 6", "Thứ 7"];
$output = $weekday[$dayOfWeek] . $nextTimeF
Chia sẻ
Đã trả lời Oct 11th, 2022 4:11 a.m.
0
$nextTimeF = date("g:i A", strtotime($nextTime));
$day = date("w", strtotime($nextTime));
$arr = array(
    '0'=> 'Chủ Nhật',
    '1'=> 'Hai',
    '2'=> 'Ba',
    '3'=> 'Tư',
    '4'=> 'Năm',
    '5'=> 'Sáu',
    '6'=> 'Bảy',
)
 switch ($day) {
        case 0:
            $day_of_week =  $arr[$day];
            break;
        default:
            $day_of_week =  "Thứ ". $arr[$day] ;  
            break;    
    }
echo $output = $day_of_week . $nextTimeF

có gì bác chỉnh lại nhé

Chia sẻ
Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí