transformer une chaine en date


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.