Solved

date and time

Posted on 2000-03-14
3
172 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
  • 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

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
Uploading Binary Data using Perl 5 83
Input from stdin for perl 6 118
Perl, group, sort, count question 6 117
Which version of C should I use when Perl is too slow? 13 173
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…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

15 Experts available now in Live!

Get 1:1 Help Now