| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/library/Helper/ |
Upload File : |
<?php
/**
* Action Helper for common functions
*/
class Zend_Controller_Action_Helper_CommonFunction extends Zend_Controller_Action_Helper_Abstract
{
/**
* @var Zend_Loader_PluginLoader
*/
public $pluginLoader;
/**
* Constructor: initialize plugin loader
*
* @return void
*/
public function __construct()
{
// $this->pluginLoader = new Zend_Loader_PluginLoader();
}
public function calculateAgeInYears($DOB)
{
// echo $DOB; // dd/mm/yyyy
//explode the date to get month, day and year
$DOB = explode("/", $DOB);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $DOB[0], $DOB[1], $DOB[2]))) > date("md")
? ((date("Y") - $DOB[2]) - 1)
: (date("Y") - $DOB[2]));
if($age==0)
{
$dob1 = $DOB[2]."-".$DOB[1]."-".$DOB[0];
$age = $this->calculateAgeInMonths($dob1);
$age = $age/12;
}
return $age;
}
public function calculateAgeInMonths($dob)
{
# yyyy-mm-dd
$birthday = new DateTime($dob);
$diff = $birthday->diff(new DateTime());
return $months = $diff->format('%m') + 12 * $diff->format('%y');
}
public function calculateDaysBwTwoDates($date1, $date2)
{
$date1 = new DateTime($date1);
$date2 = new DateTime($date2);
return $diff = $date2->diff($date1)->format("%a")+1; // number of days insured
}
public function array_search_by_name($array, $key, $value)
{
$results = array();
if (is_array($array))
{
if (isset($array[$key]) && $array[$key] == $value)
$results[] = $array;
foreach ($array as $subarray)
$results = array_merge($results, $this->array_search_by_name($subarray, $key, $value));
}
return $results;
}
}