How to print date and time in Perl

Home > Search > How-to

Use the POSIX strftime module.

use POSIX 'strftime';

my $date = "%B %d, %Y";
my $time = "%r";

print $date at $time;


This will produce a result in this format.

January 16, 2018 at 06:05:39 AM


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.