?
Solved

date and time

Posted on 2000-03-14
3
Medium Priority
?
205 Views
Last Modified: 2010-03-05
can someone pls show mi a way to get the date(day month year) and time(hour min) ?
0
Comment
Question by:prinx
[X]
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
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
alien_life_form earned 400 total points
ID: 2615973
Greetings.

#print it
print scalar(localtime());

#assign to a variable:

$now=scalar(localtime());

#get the components separately:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                                            localtime(time);

$year += 190;  #Y2k

#seconds from epoch (1/1/1970)
$snow=time();

In the array form, month is a number in the range 0-11, wday in the range 0-6.

Cheers,
    alf

0
 

Author Comment

by:prinx
ID: 2616399
so...we onli need :
#!/usr/local/bin/perl
use CGI;
$q = new CGI;
print scalar(localtime());
$now=scalar(localtime());
print $q->header();
print "$now"; #print the time
exit;

rite ?
0
 
LVL 3

Expert Comment

by:alien_life_form
ID: 2617282
Right.

Actually, you only need the second print.
The first one will actually make your script bomb (you're printing to stdout before outputting the header, and tha's a no-no).


Cheers,
      alf
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Six Sigma Control Plans

801 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