#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152433 use warnings; use Time::Piece; use Time::Seconds; { print "DAY is first, then MONTH. That is: DD/MM/YYYY\n"; @ARGV = '01/05/2023'; # DAY comes first my $t = Time::Piece->strptime("$ARGV[0] 12", "%d/%m/%Y %H"); my $daybefore = ($t - ONE_DAY)->dmy("/"); printf <strptime("$ARGV[0] 12", "%m/%d/%Y %H"); my $daybefore = ($t - ONE_DAY)->mdy("/"); printf <