CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [r00tuser] Populate time period dynamically: Edit Log



Laurent_R
Veteran / Moderator

Apr 12, 2013, 1:22 AM


Views: 694
Re: [r00tuser] Populate time period dynamically

Hmm, perhaps not very clean, but consider the following session under the debugger:


Code
  DB<1> $g = scalar gmtime 32401; 

DB<2> print $g
Thu Jan 1 09:00:01 1970
DB<3> print $1 if $g =~ /(\d\d:\d\d):\d\d/
09:00
DB<4> $g = scalar gmtime 32401 + 60*15

DB<5> print $g
Thu Jan 1 09:15:01 1970
DB<6> print $1 if $g =~ /(\d\d:\d\d):\d\d/
09:15
DB<7>


As you can see, this way you can generate time intervals of 15 minutes as you need. Something like this:


Code
my $t = 60*60*9 + 1; 
while (<>) {
my $g = scalar gmtime $t;
$t += 60*15 ; # add 15 minutes to $t;
my $timestamp = $1 if if $g =~ /(\d\d:\d\d):\d\d/;
# whatever you want to to with the input
}



(This post was edited by Laurent_R on Apr 12, 2013, 1:58 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Apr 12, 2013, 1:58 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives