Solved

getting the date in perl cgi

Posted on 2004-04-28
4
280 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 25 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

734 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