stftime format

I wrote the below function and it's working but when I want in a different format its not working
    $fileDate = POSIX::strftime( 
             "%y%m%d %H:%M:%S", 
             localtime( 
                 ( stat $inputFile)[9]
                 )
             );  

Open in new window


for the above code I got the correct output: 151213 12:00:21

but when I change the format to ccyymmdd_hhmm then I wrote the code below but it is not working where did I go wrong
    $fileDate = POSIX::strftime( 
             "%C%y%m%d_%H%M", 
             localtime( 
                 ( stat $inputFile)[9]
                 )
             );  

Open in new window

shragiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FishMongerCommented:
What value did it return?

What OS are you using and what version of perl?

Not all systems support all formats.  For example, On Windows neither %C or %T are supported.
0
shragiAuthor Commented:
I am using windows and I am using padre to write perl script
It returned: %C%y%m%d_%H%M

so what I basically trying is I am getting the file modified date from the file and I want that date in the "ccyymmdd_hhmm" format
I used the above function for other formats so far, but it did not work here.

Thanks,
0
FishMongerCommented:
Why are you using %C%y instead of %Y ?

c:\test>perl -MPOSIX  -e "print strftime('%C%y/%m/%d_%H%M', localtime)"
%C%y/%m/%d_%H%M
c:\test>perl -MPOSIX  -e "print strftime('%Y%m%d_%H%M', localtime)"
20150916_1101

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shragiAuthor Commented:
Yup %Y works but I thought to try this %C before using %Y.
well now I wrote with %Y and it works
POSIX::strftime("%Y%m%d_%H%M", localtime( ( stat $inputFile)[9]));
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.