Home > Archive > PERL Beginners > October 2006 > How to print the current year
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to print the current year
|
|
|
| Hi all,
May I know how to print the current year in yyyy format?
Please help. Thanks | |
| voichekm 2006-10-28, 11:45 pm |
| If on Unix you could do this:
my($date);
chomp($date =`date +"%Y`);
Not sure about the Windows.
Hope it helps,
Michael | |
| FishMonger 2006-10-29, 12:31 am |
| quote: Originally posted by voichekm
If on Unix you could do this:
my($date);
chomp($date =`date +"%Y`);
Not sure about the Windows.
Hope it helps,
Michael
Since this is a perl forum, here's a platform indepentent perl solution.
code:
use POSIX 'strftime';
print strftime("%Y", localtime);
|
|
|
|
|