![]() |
| perl date and time |
|
mesum98
|
I just want to know how to output the date and time in perl in following format
03:58 10/27/2005 Also if I wish to increment the time by 2 hours could anyone please help thanks m |
||||||||||||
|
|
|||||||||||||
|
bobclingan
Forum Regular
|
Did you look on CPAN? They have a nice module for formatting dates and times:
http://search.cpan.org/~rse/lcwa-1.0.0/lib/timedate/Date/Format.pm You might also find this site useful: http://datetime.perl.org/faq.html |
||||||||||||
|
|
|||||||||||||
| Can't locate DateTime.pm |
|
mesum98
|
Thanks, but I my webhost seems not to recognize the libraries
In summary my webserver supports the following modules http://j2se.co.uk/server_info/servercheck.pl?compile&7 so any advice or simple script using available modules ?? Thanks in advance |
||||||||||||
|
|
|||||||||||||
|
bobclingan
Forum Regular
|
Date format is in that list
|
||||||||||||
|
|
|||||||||||||
|
mesum98
|
My script is as bellow
#!/usr/bin/perl use Mysql; use CGI qw(:standard); my @row; use Date::Format; print "content-type: text/html\n\n"; print "<HTML><HEAD><TITLE></TITLE></HEAD>"; print "<BODY>"; @lt = timelocal(time); print time2str($template, time); print strftime($template, @lt); print time2str($template, time, $zone); print strftime($template, @lt, $zone); print ctime(time); print ascctime(@lt); print ctime(time, $zone); print asctime(@lt, $zone); print "</BODY></HTML>\n"; exit; But this does not have any output can you please put me in the correct direction |
||||||||||||
|
|
|||||||||||||
| @lt = timelocal(time); |
|
mesum98
|
I deleted @lt = timelocal(time); and it gave me the date output#Thanks
|
||||||||||||
|
|
|||||||||||||
| 03:58 10/27/2005 |
|
mesum98
|
Stuck again
can you help? Just want to format the date in the following order 03:58 10/27/2005 |
||||||||||||
|
|
|||||||||||||
|
babarrett
|
There are, of course, many ways to do this. This is one that works, feel free to improve on it.
Hope it helps. #!/usr/bin/perl use HTTP::Date; my ($date, $time) = split(" ", HTTP::Date::time2iso()); my ($hour, $min) = split(":", $time); print "$hour:$min $date\n\n"; exit; |
||||||||||||
|
|
|||||||||||||
|
spoulson
|
Love it or hate it:
|
||||||||||||||
|
|
|||||||||||||||
| perl date and time |
|
||
|


