note 105145 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Mon, 01 Aug 2011 13:51:18 +0000 |
| Subject: | note 105145 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182062@lists.php.net to get a copy of this message | ||
Note Submitter: sazer_7811 at hotmail dot com
----
con esta funcion determino la hora y fecha que le puedo asignar a un usuario en una cita. Tomando
como parametros la fecha y hora dela ultima asignada en una base de datos.
<?php
function dhcita($fecha,$hora){
$anomesdia = date("Y-m-d", strtotime("+1 days"));
$horainicio = $anomesdia.' 08:00:00';
$horafinal = $anomesdia.' 13:00:00';
$horaini = strtotime($horainicio);
$horafin = strtotime($horafinal);
$fechahora = $fecha.' '.$hora;
$fecha = strtotime($fechahora);
if ($fecha < $horaini){
$dia = $horaini;
}elseif($fecha >= $horaini and $fecha < $horafin){
$fecha = strtotime('+10 minutes',$fecha);
if($fecha < $horafin){
$dia = $fecha;
}else{
$horaini = strtotime('+1 days',$horaini);
$dia = $horaini;
}
}else
while($fecha >= $horaini){
$horaini = strtotime('+1 days',$horaini);
$horafin = strtotime('+1 days',$horafin);
if($fecha >= $horaini and $fecha < $horafin){
$fecha = strtotime('+10 minutes',$fecha);
if($fecha < $horafin){
$dia = $fecha;
}else{
$horaini = strtotime('+1 days',$horaini);
$dia = $horaini;
}
break;
}
}
return date('Y-m-d h:i:s a');// la fecha y hora de su cita es 2011-08-01 08:00:00 am
}
$fh = $dat->consulta('SELECT age_fecha, age_hora FROM agenda ORDER BY age_id DESC LIMIT
1',2);
echo 'la fecha y hora de su cita es: ',dhcita($fh[0],$fh[1]);
//dhcita('2011-07-31','12:50:00');
?>