Help for this page

Select Code to Download


  1. or download this
    use POSIX 'strftime';
    
    ...
    
        strftime $fmt, localtime(int $sec);
    }
    
  2. or download this
    # convert data2seconds, should be good until the year 2100
    
  3. or download this
    use Time::Local 'timelocal_nocheck';
    
    ...
    
    ## add milliseconds on at the end:
    $epoch .= ".$milli";
    
  4. or download this
    $sec  = "0" x (2 - length($time)).$time ;
    $msec = "0" x (3 - length($msec)).$msec ;
    
  5. or download this
    $sec  = sprintf "%02d", $time;
    $msec = sprintf "%03d", $msec;
    
  6. or download this
    ($format = $format ) =~ s/\%Y/$year/g ;  # xxxx
    ($format = $format ) =~ s/\%m/$month/g ; # 1-12
    ($format = $format ) =~ s/\%d/$day/g ;   # 01-31
    
  7. or download this
    for ($format) {
        s/%Y/$year/g;
        s/%m/$month/g;
        ...
    }
    
  8. or download this
    my %data = (
      Y => $year,
    ...
    );
    
    $format =~ s/\%([A-Za-z])/ exists $data{$1} ? $data{$1} : "%$1" /ge;