Solved

getting the date in perl cgi

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now