Re: hour -1 routine

From: Wiggins D Anconia (wiggins_at_danconia.org)
Date: 05/28/04


Date: Fri, 28 May 2004 10:37:56 -0600
To: "Anthony J Segelhorst" <ajs15@meadwestvaco.com>, beginners@perl.org


>
> I am trying to set up a script that will do the do a current time -1
> routine.
>
> Examples:
>
> Current Time:
> mmddyy:hhss
> 052804:1030
>
> Output:
> 052804:0930
>
>
> Current Time:
> 052704:0015
>
> Output:
> 052604:23:15
>
>
> I think the add_delta module is where I need to go, but I have never used
> modules before.
>

add_delta is probably a method/function in Date::Calc or Date::Manip
modules. But in this case is probably overkill.

You can use the built-in functions 'time' and 'localtime' to get the
desired effect.

perldoc -f time
perldoc -f localtime

'time' will return the current time, from which you can subtract 60*60
(60 seconds in each of 60 minutes), which gives 1 hour ago. You can then
use localtime to retrieve the values for the specific fields you need at
the calculated time. Alternatively you could use POSIX::strftime for
the formatting.

perldoc POSIX

HTH,

http://danconia.org



Relevant Pages

  • Re: Parse and Compare Text Files
    ... I've found this script on another message board that is close, ... >> Categorized Domains List ... > perldoc -f print ... > store categorized domains into an easily accessible data structure ...
    (perl.beginners)
  • Re: Critcize my scripts.
    ... > (I know it's a good practice to put use strict in Perl ... > use strict.The script below work fine if I comment out ... perldoc -f use ... Sub Routines ...
    (perl.beginners)
  • Re: Eliminating required fields in perl script for iis 6.0 server
    ... read (STDIN, $input, $ENV) or death("Can't read STDIN ... If this is a CGI script, ... or death("Could not open REF DBF during DB ... $nowlocal = localtime; ...
    (comp.lang.perl.misc)
  • Re: the code for bbs 3
    ... perldoc constant ... Consider using a template module which lets you separate output from Perl ... You are constantly referring to $PARAMSthroughout the script. ... Learn how to program, _then_ start programming. ...
    (comp.lang.perl.misc)
  • Re: qx and awk for array
    ... >> Having trouble with this command when placed in a perl script: ... I enabled warnings(use warnings;) on the script and got no warning ... > perldoc -q quoting ...
    (comp.lang.perl.misc)