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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
The day before


New User

Apr 1, 2009, 5:04 AM

Post #1 of 2 (1555 views)
The day before Can't Post

Hi Anyone :P

I'm kind of new to Perl.

I have a problem, have to know the date before the 1. day in the month, using localtime

Look at it like this:

($sec, $min, $hour, $day, $month, $year, @stuff) = localtime(time);
print join(' ', $sec, $min, $hour, $day, $month, $year );

I want to print the day before this one:)


New User

Apr 1, 2009, 5:15 AM

Post #2 of 2 (1554 views)
Re: [Kristian] The day before [In reply to] Can't Post

Hi again,

This was a newbie question, sorry for pasting it in the advanced forum..

the answer to my own question is

($sec, $min, $hour, $day, $month, $year, @stuff) = localtime(time - 86400);
print join(' ' , $sec, $min, $hour, $day, $month, $year );

because localtime calculate the date in seconds, and a day is 86400 :)

good day to you


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

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