Posted By

olive on 09/21/06


Tagged


Versions (?)

transformer une chaine en date


 / Published in: Perl
 

  1. use Time::Local;
  2. use strict;
  3.  
  4. my $input="20060920";
  5. my ($year,$month,$day) = (substr($input,0,4),substr($input,4,2),substr($input,6,2));
  6.  
  7. my $timesd = timelocal(0,0,0,$day,$month-1,$year-1900);
  8. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($timesd);
  9. print "\n".$mday."-".($mon+1)."-".($year+1900);

Report this snippet  

You need to login to post a comment.