Solved

CGI Get current day of the week

Posted on 2012-03-21
7
231 Views
Last Modified: 2012-03-23
Is there a quick way to get today's day of the week?  Getting the numeric representation would be best.

Thanks in advance.
0
Comment
Question by:kkbenj
  • 3
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 37746509
use POSIX 'strftime';
my $day = strftime '%w',localtime;
print "day=$day\n";

Open in new window

0
 

Author Comment

by:kkbenj
ID: 37746529
I have to check which modules are installed.  I will know tomorrow and test then.  Thanks for your quick response.
0
 
LVL 84

Expert Comment

by:ozo
ID: 37746530
$day=qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime)[6]];
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 48

Expert Comment

by:Tintin
ID: 37749519
The POSIX module is a core Perl module and should be included in all Perl distributions.

or following on from ozo's suggestion.

my $day = (localtime)[6];
$day++;

Open in new window

0
 
LVL 84

Expert Comment

by:ozo
ID: 37749548
the numeric representation is (localtime)[6]
0
 
LVL 48

Expert Comment

by:Tintin
ID: 37749714
Well, it does depend on whether you consider Sunday or Monday the first day of the week.
0
 
LVL 84

Expert Comment

by:ozo
ID: 37749728
or the 0th day
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl to display a matrix report for 3-dimenional array 3 63
Executing multiple sybase statements in perl dbi 2 88
Replace  text in a file 2 97
PERL - Find newest folder 12 113
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

914 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

13 Experts available now in Live!

Get 1:1 Help Now