Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Simple output of date in perl (See related posts)

// Simple output of current date in perl

  my @day_name = ("Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat.");
  my ($sec,$min,$hour,$mday,$mon,$year,$wday); 
  ($sec,$min,$hour,$mday,$mon,$year,$wday,undef,undef)=localtime(time()); $year+=1900;$mon++;
  $report_date=sprintf("%s %04d.%02d.%02d %02d:%02d",$day_name[$wday],$year,$mon,$mday,$hour,$min);

Comments on this post

radiantmatrix posts on Oct 02, 2007 at 11:45
What's wrong with:
use POSIX 'strftime';
print strtftime( '%a. %Y.%m.%d %H:%M', localtime(time()) );

?? After all, the POSIX module is included with the base Perl distribution, no sense in doing all this work yourself when strftime() will do it for you.

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts