Solved

getting the date in perl cgi

Posted on 2004-04-28
4
269 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
Comment Utility
use POSIX qw(strftime);

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

Expert Comment

by:Tintin
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
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.
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

744 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

16 Experts available now in Live!

Get 1:1 Help Now