S, Rajini (STSD) wrote:
Thanks Jacinta.
I could find date formatter that represents date in various
Fomarts.
Is there a date Converter which converts the date,
Eg : given date 27-Jan-09, to be converted to 27.01.2009.
I'd suggest looking at Date::Parse, and strftime from the POSIX module.
strftime gets my vote for the least well documented function in the
Perl core module libraries (although this may be because I haven't
studied all of the functions available). If you don't have a Unix
system available, or a copy of the ANSI C standard, then you may find
the following page helpful to build your format string:
http://opengroup.org/onlinepubs/007908799/xsh/strftime.html
for example, assuming that @dateparts contains the correct elements,
then you could convert as follows:
use POSIX qw(strftime);
my $new_date = strftime("%d.%m.%Y", @dateparts);
# $new_date is now in the correct format.
Do read the documentation for strftime though (
http://perldoc.perl.org/POSIX.html#FUNCTIONS ) because there may be
format strings on the above mentioned page that are not portable.
Generally one would pass the results of calling localtime() to strftime eg:
# The current time in dd.mm.yyyy format:
use POSIX qw(strftime);
print strftime("%d.%m.%Y", localtime());
If Date::Parse can't help you build this array, then you might want to
have a look at Date::Manip. Be aware that Date::Manip is much bigger
and slower than the purpose built modules.
All the best,
Jacinta