Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/03/2008, 19:29
jferrero
Colaborador
 
Fecha de Ingreso: mayo-2006
Ubicación: Valladolid
Mensajes: 524
Antigüedad: 18 años
Puntos: 11
Re: Pasar fecha a time y viceversa!

Código:
#!/usr/bin/perl -l
use DateTime;

my $fecha1 = DateTime->new(
    year  => 2008,
    month =>  1,
    day   =>  1,
);
my $fecha2 = DateTime->new(
    year  => 2008,
    month =>  1,
    day   => 31,
);

for (
        my $fecha = $fecha1;
        DateTime->compare($fecha, $fecha2) <= 0;
        $fecha->add( days => 1 )
    ) {

    print $fecha->ymd;
}
Código:
2008-01-01
2008-01-02
2008-01-03
2008-01-04
2008-01-05
2008-01-06
2008-01-07
2008-01-08
2008-01-09
2008-01-10
2008-01-11
2008-01-12
2008-01-13
2008-01-14
2008-01-15
2008-01-16
2008-01-17
2008-01-18
2008-01-19
2008-01-20
2008-01-21
2008-01-22
2008-01-23
2008-01-24
2008-01-25
2008-01-26
2008-01-27
2008-01-28
2008-01-29
2008-01-30
2008-01-31

Última edición por jferrero; 20/03/2008 a las 19:38