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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!