

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Questions & Answers
- 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?
- Java Program to format date time with Join
- How to get (format) date and time from mill seconds in Java?
- GMT Time in Perl
- Epoch time in Perl
- Format and Parse Date in Java
- How to use together the date and time format characters in MySQL DATE_FORMAT() function?
- C# General Date Short Time ("g") Format Specifier
- MySQL query to return the entire date and time based on a string and format
- General Date Long Time ("G") Format Specifier in C#
Advertisements