Recent Articles
- Twitter Controlled RAT (Mobile accessible), Started by gotroot in Perl
- Multiple Choice Questions in PERL, Started by ungalnanban in Perl
- Ceil/Floor/Round in Perl, Started by pradeep in Perl
- Access Amazon S3 Service using Perl, Started by pradeep in Perl
- Easy Pagination In Perl, Started by pradeep in Perl
Similar Articles
- PERL - The String Form: Expression Evaluation, Started by shree in Perl
- XML parsing in Perl, Started by pradeep in Perl
- Shortcuts in Perl, Started by pradeep in Perl
Basics
Basic formatting of datetime in Perl is done by writing your own formatting logic, we'll use the localtime function to get the current datetime details. For more info about the locatime function checkout http://perldoc.perl.org/functions/localtime.html
Code: Perl
Enter POSIX::strftime
The strftime function helps to format time information to string using pre-defined formatting parameters. Here's how we go about it, you might need a list of formatting string codes found at http://www.mkssoftware.com/docs/man3/strftime.3.asp
Code: Perl
You can format the way you like it using the format parameters, I personally feel this is the easiest way to format datetime in Perl for daily use.
Using Date::Calc
The Perl module Date::Calc's primary use is date manipulation, but it may also be used formatting dates to some extent, you may read the module's docs at http://search.cpan.org/~stbey/Date-Calc-5.4/Calc.pod
Code: Perl
Hope this write-up was helpful. Happy coding.










Yet to provide details about himself




Linear Mode

