Gossamer Forum
Home : General : Perl Programming :

can anyone tell me how would i convert yyyymmdd to yyyy,mm,dd

Quote Reply
can anyone tell me how would i convert yyyymmdd to yyyy,mm,dd
can anyone tell me how would i convert yyyymmdd to yyyy,mm,dd. Like i am getting a date as 20051004 which i want like 2005,10,04. Can anyone help me with that.
Quote Reply
Re: [sumeet] can anyone tell me how would i convert yyyymmdd to yyyy,mm,dd In reply to
Hi,

Should be as simple as;

Code:
my $str = '20040512';
if ($str =~ m/([\d\d\d\d]?)([\d\d]?)([\d\d]?)/) {
my $new_date = qq{$1,$2,$3};
}

Probably could be done better.. but that should work :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates