
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Format Date and Time in Perl
You can use localtime() function in Perl to get a list of 9-elements and later you can use the printf() function to format date and time based on your requirements as follows −
Example
#!/usr/local/bin/perl ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); printf("Time Format - HH:MM:SS\n"); printf("%02d:%02d:%02d", $hour, $min, $sec);
Output
When the above code is executed, it produces the following result −
Time Format - HH:MM:SS 06:58:52
Advertisements