in reply to How to get time in perl?

use strftime() from the POSIX module.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: How to get time in perl?
by Random_Walk (Prior) on Jul 06, 2005 at 15:08 UTC

    Just to expand on holli's excellent suggestion ...

    perl -MPOSIX -le'print strftime "%x %X", localtime time' 07/06/05 17:05:49
    There are many more formatting options, have a look at the strftime docs

    Update

    Sorry did not read the OP too closely, he wants AM or PM so this may be more like it ...
    perl -MPOSIX -le'print strftime "%r %x", localtime time' 06:47:16 PM 07/07/05

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!