in reply to Date Format Date::Calc

Use Today_and_Now() so you can get the hour/minute/second portion.

use strict; use warnings; use Date::Calc qw(Today_and_Now); print sprintf("%4d-%2d-%2d %2d:%2d:%2d.000", Today_and_Now());

Peter (Guo) Pei

Replies are listed 'Best First'.
Re^2: Date Format Date::Calc
by Marshall (Canon) on Nov 19, 2010 at 20:49 UTC
    I think you've almost got it. I would suggest adjusting the format spec to pad the 2 digit fields with leading zeroes in the case of a single digit.
    print sprintf("%4d-%02d-%02d %02d:%02d:%02d.000", Today_and_Now());
    That way you get:
    2010-11-19 12:47:07.000 instead of... 2010-11-19 12:47: 7.000