Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Yesterday's date

by tybalt89 (Monsignor)
on May 29, 2023 at 05:03 UTC ( [id://11152451]=note: print w/replies, xml ) Need Help??


in reply to Yesterday's date

Avoid all those problems with short or long days and daylight savings time switches by using the middle of the day :)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152433 use warnings; use Time::Piece; use Time::Seconds; @ARGV = '28/05/2023'; my $t = -ONE_DAY + Time::Piece->strptime("$ARGV[0] 12", "%d/%m/%Y %H") +; print localtime($t) . " should be near middle of the day\n\n"; printf "Date as supplied: %s\nDate minus one day: %s\n", $ARGV[0], $t- +>dmy("/");

Outputs:

Sat May 27 12:00:00 2023 should be near middle of the day Date as supplied: 28/05/2023 Date minus one day: 27/05/2023

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11152451]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-23 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found