HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux Bradford-Sitios 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/gestor-horarios.bradford/app/helpers/date_helper.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    function ordenarFechaServidor($date)
    {
    	$date = new DateTime($date);
		$fechaFormat = $date->format('Y-m-d H:i:s');
        return $fechaFormat;
    }
    
    function ordenarFechaHumano($date)
    {
        $explode = explode(" ", $date);
        $fecha = implode('-', array_reverse(explode('-', $explode[0])));
        return $fecha;
    }
    
    function ordenarFechaHumanoSlash($date)
    {
        $explode = explode(" ", $date);
        $fecha = implode('/', array_reverse(explode('-', $explode[0])));
        return $fecha;
    }
    
    function ordenarFechaHoraHumano($date)
    {
        $explode = explode(" ", $date);
        $fecha[] = implode('-', array_reverse(explode('-', $explode[0])));
        $tiempo  = explode(":", $explode[1]);
		$fecha[] = $tiempo[0].':'.$tiempo[1];
        return implode(' ', $fecha);
    }
	
	function ordenarFechaHoraMinutoHumano($date)
    {
        $explode = explode(" ", $date);
        $fecha[] = implode('-', array_reverse(explode('-', $explode[0])));
        $fecha[] = $explode[1];
        return implode(' ', $fecha);
    }
    
    function nowServer()
    {
        return date('Y-m-d H:i:s');
    }
    
	function hoursSpent($date, $compare)
	{
		if(empty($compare))
		{
			$compare = strtotime('now');
		}
		$seconds =strtotime($date) - $compare;
		$hours_spent=intval($seconds/60/60);
		return $hours_spent * -1;
	}
	
    function ahoraHumano()
    {
        return date('d-m-Y H:i:s');
    }
    
    function obtenerRut($data)
    {
        return substr((array_pop(explode('(', $data))),0, -1);
    }
    
    function ahoraHumanoMesAno()
    {
        $mes   = date('n');
        $meses = array('','Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'); 
        return $meses[$mes].' de '.date('Y');
    }
    
    function agregarDiasFecha($fecha,$dias, $separador = '/')
    {
        $explode = explode(" ", $fecha);
        $fecha = implode('-', array_reverse(explode('-', $explode[0])));
        $fecha = str_replace('-', '/', $fecha);
        
        list($day,$mon,$year) = explode('/',$fecha);
        return date('d'.$separador.'m'.$separador.'Y',mktime(0,0,0,$mon,$day+$dias,$year));
    }
    
    function agregarDiasFechaServidor($fecha,$dias, $separador = '/')
    {
        $explode = explode(" ", $fecha);
        $fecha = implode('-', array_reverse(explode('-', $explode[0])));
        $fecha = str_replace('-', '/', $fecha);
        
        list($day,$mon,$year) = explode('/',$fecha);
        return date('Y'.$separador.'m'.$separador.'d',mktime(0,0,0,$mon,$day+$dias,$year));
    }
    
    function dayOfweek ($dia, $mes, $ano)
    {
        $dias = array('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado');
        return $dias[date("w", mktime(0, 0, 0, $mes, $dia, $ano))];
    } 
    
    function traerNumeroDia($dia)
    {
        $return = '';
        $dias = array(1 =>'Lunes', 2 => 'Martes', 3 =>'Miércoles', 4 =>'Jueves', 5 =>'Viernes', 6 =>'Sábado', 7 =>'Domingo');
        foreach ($dias as $key => $value)
        {
            if($value == $dia)
            {
                $return = $key;
            }
        }
        return $return;
    }
    
     function traerTextoDia($dia)
    {
        $return = '';
        $dias = array(1 =>'Lunes', 2 => 'Martes', 3 =>'Miércoles', 4 =>'Jueves', 5 =>'Viernes', 6 =>'Sábado', 7 =>'Domingo');
        foreach ($dias as $key => $value)
        {
            if($key == $dia)
            {
                $return = $value;
            }
        }
        return $return;
    }
    
    
    function traerNumeroMes($mes)
    {
        $return = '';
        $meses = array(1 =>"Enero", 2 => "Febrero",3 =>"Marzo", 4 => "Abril", 5 => "Mayo", 6 =>"Junio",
                       7 =>"Julio", 8 => "Agosto", 9 => "Septiembre",10 => "Octubre",11 => "Noviembre", 12 => "Diciembre");
        foreach ($meses as $key => $value)
        {
            if($value == $mes)
            {
                $return = $key;
            }
        }
        return $return;
    }
    
    function getMonthName($mes)
    {
        $return = '';
        $meses = array(1 =>"Enero", 2 => "Febrero",3 =>"Marzo", 4 => "Abril", 5 => "Mayo", 6 =>"Junio",
                       7 =>"Julio", 8 => "Agosto", 9 => "Septiembre",10 => "Octubre",11 => "Noviembre", 12 => "Diciembre");
        foreach ($meses as $key => $value)
        {
            if($key == $mes)
            {
                $return = $value;
            }
        }
        return $return;
    }
       
    function traerMeses()
    {
        $return = '';
        return array(1 =>"Enero", 2 => "Febrero",3 =>"Marzo", 4 => "Abril", 5 => "Mayo", 6 =>"Junio",
                     7 =>"Julio", 8 => "Agosto", 9 => "Septiembre",10 => "Octubre",11 => "Noviembre", 12 => "Diciembre");
        
    }

    function timeToMinutes($time) {
        list($hours, $minutes) = explode(':', $time);
        return $hours * 60 + $minutes;
    }
    
    function minutesToTime($totalMinutes) {
        $hours = floor($totalMinutes / 60);
        $minutes = $totalMinutes % 60;
        return "$hours hora(s) con $minutes minuto(s)";
    }

    function differenceInMinutes($start, $end) {
        list($startHours, $startMinutes) = explode(':', $start);
        list($endHours, $endMinutes) = explode(':', $end);
        
        $startTotalMinutes = $startHours * 60 + $startMinutes;
        $endTotalMinutes = $endHours * 60 + $endMinutes;
        
        return $endTotalMinutes - $startTotalMinutes;
    }