Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i display date using perl ?

Status
Not open for further replies.

alanchia

Technical User
Jan 8, 2003
42
0
0
SG
hi all,

what command should is use to display date using perl ?

thanks
alan
 
Try the following:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$sec=sprintf("%02d",$sec);
$min=sprintf("%02d",$min);
$hour=sprintf("%02d",$hour);
$mday=sprintf("%02d", $mday);
$mon=sprintf("%02d", $mon+1);
$year=sprintf("%04d", $year+1900);
print "$mday:$mon:$year\n";
 
You could also use:

print `/usr/bin/date`;

Those are backtiks and not single quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top