Help for this page

Select Code to Download


  1. or download this
    my ($y, $m, $d) = unpack('a4a2a2', $str);
    
  2. or download this
    my $y = substr($str, 0, 4);
    my $m = substr($str, 4, 2);
    my $d = substr($str, 6, 2);
    
  3. or download this
    my ($y, $m, $d) = $str =~ /(.{4})(.{2})(.{2})/;
    
  4. or download this
    $str =~ /(.{4})/g;  my $y = $1;
    $str =~ /(.{2})/g;  my $m = $1;
    $str =~ /(.{2})/g;  my $d = $1;
    
  5. or download this
    my ($y, $m, $d) = map { 0+$_ } unpack('a4a2a2', $str);
    
  6. or download this
    printf("%04d/%02d/%02d\n", $y, $m, $d);
    
  7. or download this
    $formatted = sprintf("%04d/%02d/%02d", $y, $m, $d);