Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

the next day's date

by Anonymous Monk
on Aug 07, 2002 at 19:13 UTC ( [id://188431]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a perl routine that will get the next day's
date? For example; if today is 8/7/2002 how could I
get 8/8/2002? Even if the date is 8/31/2002, how
could i get 9/1/2002? thanks in advance

Replies are listed 'Best First'.
Re: the next day's date
by dws (Chancellor) on Aug 07, 2002 at 19:19 UTC
    Is there a perl routine that will get the next day's date?

    If you don't mind to narrow little 1 hour windows when daylight savings time transitions will give you the wrong answer (in terms of absolute time, but not date), you can do $tomorrow = time() + 24*60*60; and then use localtime() to pick $tomorrow apart into pieces. Or, you can check out Date::Manip.

      I'll second the recommendation for Date::Manip; it will even let you "Date_GetNextWorkDay", letting you specify the holidays that apply in your context.
      --
      Mike
Re: the next day's date
by Anonymous Monk on Aug 07, 2002 at 19:38 UTC
    sub next_day { sleep 86400; return localtime(); }
      But then you have to wait a day. It can be optimized:
      sub next_day { sleep 24 * 60 * 60; my $date = localtime; sleep -24 * 60 * 60; return $date; }
      Abigail
Re: the next day's date
by tadman (Prior) on Aug 07, 2002 at 19:26 UTC
    You can use Date::Calc of course (or Date::Manip).

    I'm almost in agreement with dws, except that time is a concept that is ethreal at best. If you're in a region plagued by "daylight savings time", then this may not work during that small window where a day has only 23 hours, or perhaps 25. It's like changing time-zones even though you're sitting still.
Re: the next day's date
by Abigail-II (Bishop) on Aug 08, 2002 at 09:49 UTC
    $ perl -MDate::Manip -wle 'print UnixDate ParseDate ("tomorrow") => + "%u"' Fri Aug 9 11:48:57 +0200 2002 $
    Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found