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
Solved

getting the date in perl cgi

Posted on 2004-04-28
4
274 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 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