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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing out a formated date

Status
Not open for further replies.

DarVar

Programmer
Mar 14, 2006
10
IE
Hi I want to be able to print out the date in a formatted string

The format doesn't particularly matter
Something like this
Tue Mar 28 16:02:04

I read about localtime??

print "$localtime
 
Without wishing to preach RTFM too much - have you looked at this page whcih gives all the perl builtin functions.

Columb Healy
 
How about this:
Code:
#!/usr/bin/perl

use strict;
use warnings;

my $now = scalar(localtime(time));

print $now;

Let us know your results!

X
 
or simply:

print scalar localtime();

if you wanted to print the current time and date, or:

print scalar gmtime();

for gm time.
 
Hi,
I used the code posted by Xaqte

It works fine on its own but I get the following printed out in my script:
Time::tm=ARRAY(0x1c3148)[Time::tm=ARRAY(0x1c3148)]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top