?
Solved

getting the date in perl cgi

Posted on 2004-04-28
4
Medium Priority
?
287 Views
Last Modified: 2013-12-25
i want to display the current date using a print "todays date is xxxxxxx"

i would like to use date +%V

what is the correct way to do this
0
Comment
Question by:plennon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
kandura earned 75 total points
ID: 10943267
use POSIX qw(strftime);

$date = strftime "%V", localtime();
0
 
LVL 48

Expert Comment

by:Tintin
ID: 10944077
use POSIX qw(strftime);

print "todays ISO 8601 week number is " . strftime("%V\n",localtime);
print "todays date is " . strftime("%x\n",localtime();
0
 
LVL 9

Expert Comment

by:ronan_40060
ID: 10962429
this worked for me
@date = localtime;
 my $dayofmon = $date[3];
my $mon = $date[4] + 1;
 my $year = $date[5] + 1900;
print "today's date is ${mon}/${dayofmon}/${year}\n"; # outputs - today's date is 4/30/2004

hope it helps
0
 
LVL 48

Expert Comment

by:Tintin
ID: 10973707
ronan_40060.

That's a very clunky way of getting the date.  Best option is using the POSIX module, but if not, then you can do

my ($day,$mon,$year) = (localtime)[3..5];
printf("Todays date is  %02d/%02d/%y\n",$day,$mon++,$year+1900);

BTW, I would not recommend using ambiguous date formats that the majority of the world doesn't use.
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question