System time: Difference between revisions
Content added Content deleted
m (Added output) |
(Add perl version.) |
||
Line 64:
}
Other methods are available in the <tt>Date</tt> object such as: getDay(), getHours(), getMinutes(), getSeconds(), getYear(), etc.
=={{header|Perl}}==
Simple localtime use in scalar context.
print scalar localtime, "\n";
Output:
Thu Jan 24 11:23:30 2008
localtime use in array context.
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
printf("%04d-%02d-%02d %02d:%02d:%02d\n", $year + 1900, $mon + 1, $mday, $hour, $min, $sec);
Output:
2008-01-24 11:23:30
localtime use in array context with POSIX strftime.
use POSIX qw(strftime);
my $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
print "$now_string\n";
Output (with cs_CZ.UTF-8 locale):
Čt led 24 11:23:30 2008
==See Also==
|