Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Find 30 days from today's date

by ikegami (Pope)
on Jun 09, 2013 at 06:05 UTC ( #1037906=note: print w/ replies, xml ) Need Help??


in reply to Re: Find 30 days from today's date
in thread Find 30 days from today's date

If he wants the date where his computer is located (as opposed to the date somewhere in Europe),

my $thirty_days_ago = DateTime->today(time_zone => 'local')->subtract( +days => 30);

Note that the above solution will fail two days a year in time zones with no midnight on a DST change. (There is at least one such time zone.) Workaround:

my $thirty_days_ago = DateTime->now(time_zone => 'local')->set_hour(12 +)->subtract(days => 30);


Comment on Re^2: Find 30 days from today's date
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2014-09-24 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (244 votes), past polls