public
Created

Custom Date (Bahasa Indonesia) Helper

  • Download Gist
gistfile1.php
PHP
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
 
function custom_date($timestamp = NULL, $format = 'd F, Y')
{
$l = array('', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum\'at', 'Sabtu', 'Minggu');
$F = array('', 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember');
$return = '';
if(is_null($timestamp)) { $timestamp = mktime(); }
for($i = 0, $len = strlen($format); $i < $len; $i++) {
switch($format[$i]) {
case '\\' :
$i++;
$return .= isset($format[$i]) ? $format[$i] : '';
break;
case 'l' :
$return .= $l[date('N', $timestamp)];
break;
case 'F' :
$return .= $F[date('n', $timestamp)];
break;
default :
$return .= date($format[$i], $timestamp);
break;
}
}
return $return;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.