in reply to Epoch to specific output

This *seems* to do what you are asking, at least for my first test:

perl -MPOSIX -e 'my $t = time; print strftime("%m%d%H%M", gmtime $t);'
You could use localtime in place of gmtime, but then you would have to consider what you want to occur when there are DST (daylight saving time) changes.

Hope that helps.

Replies are listed 'Best First'.
Re^2: Epoch to specific output
by Anonymous Monk on Jan 02, 2014 at 18:47 UTC

    Your suggestion works well with a direct input for time. However, I was unable to substitute time with the $x variable.

    I was able to get it to work though with the following code:

    echo $x|perl -MPOSIX -e 'print strftime("%m%d%H%M", gmtime <stdin>)'

    Thank you everyone for your help!

      Pass your variable as an additional argument, use @ARGV to get it from inside the program:
      perl -MPOSIX -le'print strftime("%m%d%H%M", gmtime $ARGV[0])' "$x"
        Or just use shift:
        perl -MPOSIX -le 'print strftime("%m%d%H%M", gmtime shift)' "$x"
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ