Solved

How do I get day if I know the date ?

Posted on 2002-04-11
3
189 Views
Last Modified: 2010-03-05
How do I know what day it is for 20020401 ?
0
Comment
Question by:tcy08
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 6934396
use Time::Local;
$date = "20020401";
($y,$m,$d)=unpack"a4a2a2",$date;
$day=("Sun","Mon","Tue","Wed","Thu","Fri","Sat")[(gmtime timegm 0,0,0,$d,$m-1,$y-1900)[6]];
0
 

Author Comment

by:tcy08
ID: 6934425
ozo,

can you give me more explanation for the code ?
0
 
LVL 6

Expert Comment

by:Talmash
ID: 6934451
hi ,

# assume $date is what you have

my @date_arr = split("",$date);
my $day = join("",$date_arr[6],$date_arr[7]);

printf "date = $date , day = $day \n";

COMMENT :

date +%Y%m%d

gives

20020411

date +%d

gives

11
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
Passing shell scripts to run on the SFTP cmd object 12 180
How to strip .csv from file name 9 78
Parse csv file and generate graphs in HTML in bash 8 156
create a gui in perl 3 67
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 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

20 Experts available now in Live!

Get 1:1 Help Now