Solved

date and time

Posted on 2000-03-14
3
203 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 100 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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

691 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