17Sep/070
Get Previous Month
Ide awal dapat dari sini, saya hanya mengubah supaya bisa dinamis sesuai parameter.
<?php
function getPrevMonth($y, $m){
list($yx, $mx) = (ltrim($m, '0') == 1)?
array($y-1, '12') :
array($y, str_pad($m-1, 2, '0', STR_PAD_LEFT));
$date = mktime(0, 0, 0, $mx, 1, $yx);
$strDate1 = $yx.'-'.$mx.'-'.'01';
$strDate2 = $yx.'-'.$mx.'-'.date('t', $date);
return array($strDate1, $strDate2);
}
echo '<pre>';print_r (getPrevMonth('2007', '09'));echo '</pre>';
echo '<pre>';print_r (getPrevMonth('2007', '07'));echo '</pre>';
echo '<pre>';print_r (getPrevMonth('2007', '06'));echo '</pre>';
?>
Silahkan dipakai dan diubah sesuai keperluan, hak cipta bukan milik saya.
14Jul/070
Date Form Helper Functions
Many of my project is require user to input date into form. Therefore, I need functions that I can reuse it on my other project. This function actually is a complement to CodeIgniter's form helper. Here's the script :
7Apr/070
Creating Dropdown Selector for Date Function
Sometimes, we need to create a form that need a date selection. Here's how I handle this thing. First, let us create some function to do this :








