-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03-tanggal-dan-waktu-format-indo.php
More file actions
51 lines (39 loc) · 1.11 KB
/
03-tanggal-dan-waktu-format-indo.php
File metadata and controls
51 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
setlocale(LC_TIME, 'id_ID.utf8');
# pendekatan prosedural
echo date('D M y, H:i') . '<br>';
# pendekatan objek
$hariIni = new DateTime();
echo $hariIni->format('l F Y, H:i') . '<br>';
echo "<hr>";
$hariIni = new DateTime();
echo $hariIni->format('l F Y, H:i') . '<br>';
echo $hariIni->format('D M y, H:i') . '<br>';
echo "<br>";
echo strftime('%A %d %B %Y, %H:%M', $hariIni->getTimestamp()) . '<br>';
echo strftime('%a %d %b %Y, %H:%M', $hariIni->getTimestamp()) . '<br>';
echo "<hr>";
function hariIndo ($hariInggris) {
switch ($hariInggris) {
case 'Sunday':
return 'Minggu';
case 'Monday':
return 'Senin';
case 'Tuesday':
return 'Selasa';
case 'Wednesday':
return 'Rabu';
case 'Thursday':
return 'Kamis';
case 'Friday':
return 'Jumat';
case 'Saturday':
return 'Sabtu';
default:
return 'hari tidak valid';
}
}
$hariBahasaInggris = date('l');
$hariBahasaIndonesia = hariIndo($hariBahasaInggris);
echo "Bahasa Inggris: {$hariBahasaInggris} <br>";
echo "Bahasa Indonesia: {$hariBahasaIndonesia} <br>";