You are Here: FAQ ->Scripting & Programming->Perl->Article #1


WebHosting 5.0 This article is for 1&1 Linux WebHosting only.


How can I find one time and/or a date out with Perl?




With a combination of the functions localtime() and time() the announcement of one time and/or a date is possible:

Script 1: date.pl

#!/usr/bin/perl
print "content type: text/html\n\n ";
$a=localtime(time());
@arr_time = split(/ + /, $a);
print "The Date and Time is: ";
for(@arr_time) {print $_."*";}


An array is returned. The individual fields can call you up with # ] ( whereby x stands for a number between 0 and 4). The expenditure of the programme looks above then for example as follows:

Sat*May*27*20:09:33*2000 *


See this script in action Click Here.


Print Article
How useful was this article?
(From 5 = Very Useful to 1 = Not Very Useful at all):
1 2 3 4 5