Tuesday, June 8, 2021

Formatting Time and Date with Perl

# timestamp examples
use strict;
use warnings;
use v5.10.0;

use POSIX qq(strftime);

my $timestamp = strftime("%Y-%m-%d_%a_%H-%M-%S",localtime);

say $timestamp; # 2021-06-08_Tue_11-54-28

# ------------------------------------------------------------------------------

use DateTime;

my $today = DateTime->today();

say $today; # 2021-06-08T00:00:00

say $today->date; # 2021-06-08

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.