/**
  * fixDate - Date Conversion Between Different Formats
  * @param String $input_date Date to be converted
  * @param String $date_format Target Date Format
  */
 public function fixDate($input_date, $output_format = null, $input_format = null)
 {
     if (!$input_date) {
         return;
     }
     $input_date = preg_replace('/T|Z/', ' ', $input_date);
     $temp = explode(' ', $input_date);
     //split using space and consider the first portion, in case of date with time
     $input_date = $temp[0];
     $output_format = \Application\Model\ApplicationTable::dateFormat($output_format);
     $input_format = \Application\Model\ApplicationTable::dateFormat($input_format);
     preg_match("/[^ymd]/", $output_format, $date_seperator_output);
     $seperator_output = $date_seperator_output[0];
     $output_date_arr = explode($seperator_output, $output_format);
     preg_match("/[^ymd]/", $input_format, $date_seperator_input);
     $seperator_input = $date_seperator_input[0];
     $input_date_array = explode($seperator_input, $input_format);
     preg_match("/[^1234567890]/", $input_date, $date_seperator_input);
     $seperator_input = $date_seperator_input[0];
     $input_date_arr = explode($seperator_input, $input_date);
     foreach ($output_date_arr as $key => $format) {
         $index = array_search($format, $input_date_array);
         $output_date_arr[$key] = $input_date_arr[$index];
     }
     $output_date = implode($seperator_output, $output_date_arr);
     $output_date = $temp[1] ? $output_date . " " . $temp[1] : $output_date;
     //append the time, if exists, with the new formatted date
     return $output_date;
 }
 public function __construct($sm)
 {
     $this->listenerObject = new Listener();
     $this->date_format = \Application\Model\ApplicationTable::dateFormat($GLOBALS['date_display_format']);
 }