Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.147.75.217
<?php
function db_date_Format($date)
{
if(empty($date))
return "0000-00-00";
$FromDate_exp=explode("/",$date);
$date=trim($FromDate_exp[2])."-".trim($FromDate_exp[1])."-".trim($FromDate_exp[0]);
return trim($date);
}
function ddmmyyDateFormatWithDot($date)
{
$date=trim($date);
$FromDate_exp=explode(".",$date);
$date=trim($FromDate_exp[0])."/".trim($FromDate_exp[1])."/".trim($FromDate_exp[2]);
return trim($date);
}
function GetDbDateFormatFromExcel($date_str)
{
$month_arr=array('jan'=>'01','feb'=>'02','mar'=>'03','apr'=>'04',
'may'=>'05','jun'=>'06','jul'=>'07','aug'=>'08',
'sep'=>'09','oct'=>'10','nov'=>'11','dec'=>'12');
if(empty($date_str))
$db_date='0000-00-00';
$pattern = "/[\/]+/";
if(preg_match($pattern,$date_str))//if they have given dd/mm/yy
{
$date_obj=explode("/",$date_str);
$year=$date_obj[2];
$month=substr("0".$date_obj[1],-2);
$day=substr("0".$date_obj[0],-2);
$db_date=$year.'-'.$month.'-'.$day;
}
else//if they have given in 01-jun-1980
{
if(is_numeric($date_str))
{
$timestamp = ($date_str - 25569) * 86400;
$db_date=date("Y-m-d",$timestamp);
}
else
{
$date_obj=explode("-",$date_str);
if(count($date_obj)!=3)
$db_date='0000-00-00';
else
{
$year_id=$date_obj[2];
$pattern = "/^[a-zA-Z]*$/";
if(preg_match($pattern,$date_obj[0]))
{
$month_name=strtolower($date_obj[0]);
$month_id=$month_arr[$month_name];
$day=substr("0".$date_obj[1],-2);
}
else
{
$month_name=strtolower($date_obj[1]);
$month_id=$month_arr[$month_name];
$day=substr("0".$date_obj[0],-2);
}
$db_date=$year_id.'-'.$month_id.'-'.$day;
}
}
}
return $db_date;
}
function ui_date_Format($date)
{
$FromDate_exp=explode("-",$date);
$date=$FromDate_exp[2]."/".$FromDate_exp[1]."/".$FromDate_exp[0];
if($date=="//" || empty($date))
$date="00/00/0000";
return $date;
} function UIDateTimeFormat($date_val)
{
$date_arr=explode(" ",$date_val);
$date=$date_arr[0];
$time=$date_arr[1];
$FromDate_exp=explode("-",$date);
$date=$FromDate_exp[2]."/".$FromDate_exp[1]."/".$FromDate_exp[0];
if($date=="//")
$date="00/00/0000";
return $date." ".$time;
} function ind_ui_date_Format($date)
{
$date=trim($date);
$FromDate_exp=explode("/",$date);
$date=trim($FromDate_exp[1])."/".trim($FromDate_exp[0])."/".trim($FromDate_exp[2]);
return trim($date);
}
function getHostDomain()
{
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
return $main_src;
}
function getMonthNameYearByDate($date)
{
# format ddmmyyyy
$date_arr = explode('/',$date);
$month_index = $date_arr[1];
$month_name = getMonthInFullName($month_index).' '.$date_arr[2] ;
return($month_name);
}
function GetRamcoDateFormat($date)//AUG-14
{
$date=trim($date);
$exp_str=explode("-",$date);
$new_date="20".substr($exp_str[1],-2).getMonthInInteger(strtoupper($exp_str[0]));
return $new_date;
}
function GetRamcoDBDateFullFormat($date)//01-Apr-2011
{
if(empty($date))
{
return "0000-00-00";
}
$date=trim($date);
$exp_str=explode("-",$date);
$new_date=$exp_str[2]."-".getMonthInInteger(strtoupper($exp_str[1]))."-".$exp_str[0];
return $new_date;
}
function GetMonthIdFromMonthString($date)//AUG-14
{
$date=trim($date);
$exp_str=explode("-",$date);
$new_date= substr($exp_str[1],-4).getMonthInInteger(strtoupper($exp_str[0]));
return $new_date;
}
function getMonthInInteger($month_index)
{
$titles_Month['JAN'] = "01";
$titles_Month['FEB'] = "02";
$titles_Month['MAR'] = "03";
$titles_Month['APR'] = "04";
$titles_Month['MAY'] = "05";
$titles_Month['JUN'] = "06";
$titles_Month['JUL'] = "07";
$titles_Month['AUG'] = "08";
$titles_Month['SEP'] = "09";
$titles_Month['OCT'] = "10";
$titles_Month['NOV'] = "11";
$titles_Month['DEC'] = "12";
return ($titles_Month[trim($month_index)]);
}
function getMonthInName($month_index)
{
$month_name['01'] = "JAN";
$month_name['02'] = "FEB";
$month_name['03'] = "MAR";
$month_name['04'] = "APR";
$month_name['05'] = "MAY";
$month_name['06'] = "JUN";
$month_name['07'] = "JUL";
$month_name['08'] = "AUG";
$month_name['09'] = "SEP";
$month_name['10'] = "OCT";
$month_name['11'] = "NOV";
$month_name['12'] = "DEC";
return ($month_name[trim($month_index)]);
}
function getMonthInFullName($month_index)
{
$month_name['01'] = "January";
$month_name['02'] = "February";
$month_name['03'] = "March";
$month_name['04'] = "April";
$month_name['05'] = "May";
$month_name['06'] = "June";
$month_name['07'] = "July";
$month_name['08'] = "August";
$month_name['09'] = "September";
$month_name['10'] = "October";
$month_name['11'] = "November";
$month_name['12'] = "December";
return ($month_name[trim($month_index)]);
}
function getPeriodFromEfftDate($eff_date)
{
#format ddmmyy
$period_arr = explode('/',$eff_date);
$period = $period_arr[2].$period_arr[1];
return($period);
}
function ui_month_format($str)
{
if(!empty($str))
{
$year=substr($str,0,4);
$month=substr($str,-2);
$month_name['01'] = "Jan";
$month_name['02'] = "Feb";
$month_name['03'] = "Mar";
$month_name['04'] = "Apr";
$month_name['05'] = "May";
$month_name['06'] = "Jun";
$month_name['07'] = "Jul";
$month_name['08'] = "Aug";
$month_name['09'] = "Sep";
$month_name['10'] = "Oct";
$month_name['11'] = "Nov";
$month_name['12'] = "Dec";
return ($month_name[$month].'-'.$year);
}
else
{
return '';
}
}
function get_months_year($Start_date,$End_date,$month_type='full')
{
if($month_type=='full')
$month_name="F";
else
$month_name="M";
$time1 = strtotime($Start_date);
$time2 = strtotime($End_date);
$my = date('mY', $time2);
$months = array(date("{$month_name}", $time1));
while($time1 < $time2) {
$time1 = strtotime(date('Y-m-d', $time1).' +1 month');
if(date('mY', $time1) != $my && ($time1 < $time2))
$months[] = date("{$month_name}", $time1);
}
$months[] = date("{$month_name}", $time2);
return $months;
}
function get_col_name()
{
$cnt=0;
$col= array();
for($i = 'a'; $i <= 'zz'; $i++)
{
if($i=='iw') break;
$col[$cnt]=strtoupper($i);
$cnt++;
}
return $col;
}
function rmdir_recursive($dir)
{
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) continue;
if (is_dir("$dir/$file")) $this->rmdir_recursive("$dir/$file");
else
{
// echo "$dir/$file<br>";
unlink("$dir/$file");
}
}
rmdir($dir);
}
?>
|