Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Yesterday's date

by choroba (Cardinal)
on May 28, 2023 at 20:02 UTC ( [id://11152442]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Yesterday's date
in thread Yesterday's date

> Note that this approach will have a problem for those days with less than 24 hours

If you want Time::Piece to respect time zones, you need to initialize the object from localtime, not from the class itself:

$ TZ=Europe/London perl -MTime::Piece -wE ' for my $source ("Time::Piece", scalar localtime()) { my $t = $source->strptime("2023/03/27", "%Y/%m/%d"); say $t - 86400; }' Sun Mar 26 00:00:00 2023 Sat Mar 25 23:00:00 2023

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-24 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found