[Tanya-Bertanya] para agan yang master2 Fungsi PH... Aug 7th 2013, 07:23, by Ridho Tobing No Xvii | [Tanya-Bertanya] para agan yang master2
Fungsi PHP untuk mendapatkan nama Hari dalam bahasa Indonesia dari database yang berformat 'date' misal : di record tanggal = '2013-08-01' dari record itu bisa didapatkan nama harinya sesuai dengan tanggal sebenarnya Mintol solusi nya master |
| | gunakan select date_format |
| | ane gunakan date_format(tanggal, '%D/%m/%Y') hasilnya 1st-08-2013 |
| | SELECT DATE_FORMAT(tanggal, '%d %F %Y') as Tanggal |
| | untuk parameter
d -> day 1 digit D -> day 2 digit : 02 m -> bln 2 digit : 12 M -> bln 3 digit : Jun , Apr F -> bln full : January, Februari, March y -> thn 2 digit : 90 Y -> thn 4 digit : 2013 |
| | tes dulu yak |
| | ini referensi nya http://www.w3schools.com/sql/func_date_format.asp |
| | (Y) |
| | day name itu %w lihat di link yang ane kasih |
| | %F = F |
| | %w , lihat link diatas itu ane kasih lengkap
ini ane pastein :v
The formats that can be used are:
Format Description %a Abbreviated weekday name %b Abbreviated month name %c Month, numeric %D Day of month with English suffix %d Day of month, numeric (00-31) %e Day of month, numeric (0-31) %f Microseconds %H Hour (00-23) %h Hour (01-12) %I Hour (01-12) %i Minutes, numeric (00-59) %j Day of year (001-366) %k Hour (0-23) %l Hour (1-12) %M Month name %m Month, numeric (00-12) %p AM or PM %r Time, 12-hour (hh:mm:ss AM or PM) %S Seconds (00-59) %s Seconds (00-59) %T Time, 24-hour (hh:mm:ss) %U Week (00-53) where Sunday is the first day of week %u Week (00-53) where Monday is the first day of week %V Week (01-53) where Sunday is the first day of week, used with %X %v Week (01-53) where Monday is the first day of week, used with %x %W Weekday name %w Day of the week (0=Sunday, 6=Saturday) %X Year of the week where Sunday is the first day of week, four digits, used with %V %x Year of the week where Monday is the first day of week, four digits, used with %v %Y Year, four digits %y Year, two digits |
| | pertanyaanya nama hari kan? adanya bhs inggris tp bs aja dibuat return angka harinya lalu dipake mengindex array yg berisi nama2 hari dlm bhs ind.
$hari = array("Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"); echo $hari[date("w", $tanggalmutadi)]; |
| | nemu.. |
| | Al Ghurahy .. <? $hari = array("Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"); echo $hari[date("w", 2013-08-13)]; ?>
outputnya==kamis |
| | (Y) |
| | wah salah dong? coba cek dl udah bener gak output angka yg jd index nya?
pd prinsipnya date("w", $tanggal) ngikut ini:
http://php.net/manual/en/function.date.php
jd keluarnya angka 0 s.d 6 (minggu s.d sabtu)
kl salah mngkn hrs
$index = date("w", strtotime($string_tanggalanmu)); | |
Tidak ada komentar:
Posting Komentar