- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- 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 −
#!/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);
When the above code is executed, it produces the following result −
Time Format - HH:MM:SS 06:58:52
- Related Articles
- Current Date and Time in Perl
- How to format date and time in android?
- How to change date and time format in Android sqlite?
- How to change date time format in HTML5?
- How to print date and time in specific format using JSP?
- How do you format date and time in Android using Kotlin?
- General Date Long Time ("G") Format Specifier in C#
- Full Date Short Time ("f") Format Specifier in C#
- Full Date Long Time ("F") Format Specifier in C#
- How to get (format) date and time from mill seconds in Java?
- Java Program to format date time with Join
- C# General Date Short Time ("g") Format Specifier
- How to use together the date and time format characters in MySQL DATE_FORMAT() function?
- Format and Parse Date in Java
- GMT Time in Perl