Getting system date as DD MMM YYYY

Hi,

Guess this is pretty simple if you know what you're doing, but all I need to know is the full code for getting the system date into a variable in a Perl Script in the following format:

eg) 25 DEC 1999

Many thanks,
Dave

LVL 1
dgb001Asked:
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.

vaksCommented:
On UNIX you could do:

$date = `date +"%d %b %Y"`;

The month will, however, come as "Dec" and not "DEC".

Note that the ` looks like a small \

Regards
Vaks
0
dgb001Author Commented:
Yep, that's great - post it as an answer and I can throw you some points.

Thanks for your help,
Dave
0
prakashk021799Commented:
If you do a lot of date manipulation, get the module Date::Manip from a CPAN archive near you. It is a very useful module.

Once you have it, just do:

use Date::Manip;

# get system date in DD MMM YY format
$today = UnixDate('today', '%d %b %y');

# if you want the month in upper case,
# change the above line to:
$today = uc UnixDate('today', '%d %b %y');

For one time use, it might be overkill to use this module.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

prakashk021799Commented:
#Change the year format to get 4-digit year (%y to %Y)

# get system date in DD MMM YYYY format
$today = uc UnixDate('today', '%d %b %Y');
0
dgb001Author Commented:
Thanks Prakashk,

That looks useful. In actual fact the previous comment proved to be just what I wanted for the current task, but your comments definitely look like something I can make more use of in the future.

Thanks very much,
Dave
0
vaksCommented:
On UNIX you could do:

$date = `date +"%d %b %Y"`;

The month will, however, come as "Dec" and not "DEC".

Note that the ` looks like a small \

Regards
Vaks
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
ozoCommented:
($date=localtime)=~s/\w+( \w+ )(\d+).* /$2\U$1/;
0
dgb001Author Commented:
Thanks ozo,

Dave
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.