Skip to content

Instantly share code, notes, and snippets.

@dwihujianto
Created November 12, 2015 06:56
Show Gist options
  • Save dwihujianto/f74151944f54872cba3f to your computer and use it in GitHub Desktop.
Save dwihujianto/f74151944f54872cba3f to your computer and use it in GitHub Desktop.
Helper tanggal indonesia (Codeigniter 3.03)
<?php defined('BASEPATH') OR exit('Forbbiden');
if (! function_exists('indodate'))
{
function indodate($date='')
{
$Arrmonth = [
1 => 'Januari',
2 => 'Februari',
3 => 'Maret',
4 => 'April',
5 => 'Mei',
6 => 'Juni',
7 => 'Juli',
8 => 'Agustus',
9 => 'September',
10 => 'Oktober',
11 => 'November',
12 => 'Desember'
];
$olddate = explode('-', $date);
$year = $olddate[0];
$month = $Arrmonth[$olddate[1]];
$day = $olddate[2];
$newdate = $day.' '.$month.' '.$year;
return $newdate;
}
}
if (! function_exists('indodatetime'))
{
function indodatetime($data)
{
$Arrmonth = [1=>'Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember'];
$origin = explode('-', $data);
$year = $origin[0];
$month = $Arrmonth[$origin[1]];
$originday = explode(' ', $origin[2]);
$day = $originday[0];
$newdatetime = $originday[1].' '.$day.' '.$month.' '.$year;
return $newdatetime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment