Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: time & localtime() function Q?

by mitd (Curate)
on Nov 22, 2001 at 23:06 UTC ( #127001=note: print w/replies, xml ) Need Help??

in reply to time & localtime() function Q?

time() returns the number of SECS since Epoch. Epoch can vary from OS to OS but localtime(time) if used in a scalar context will return a human readable date.
my $datetime = localtime(time); # returns Thu Nov 22 13:05:26 2001 # (well at least it did at the time() )
For your continuing date manipulation needs Date::Calc, Date::Manip and Date::Format will quickly become your friends.

mitd-Made in the Dark
'Interactive! Paper tape is interactive!
If you don't believe me I can show you my paper cut scars!'

Replies are listed 'Best First'.
Re: Re: time & localtime() function Q?
by fuzzysteve (Beadle) on Nov 23, 2001 at 06:49 UTC
    Date::manip is the way to go.
    It handles the addition of periods of time to a date, and while the documentation doesn't mention it, using
    $date=&DateCalc("today","+ 1week",\$err);
    Would almost certainly work to set date to one week from today.
Re: Re: time & localtime() function Q?
by Gerryjun (Scribe) on Nov 22, 2001 at 23:12 UTC
    what would time() return in unix and windows? what dose it mean?

    im creating in windows but will need to upload on a unix server.
      If you mean you are writing/testing code on windows and uploading to Unix then don't worry things will work as expected ie localtime() will do the right thing. time and localtime() in Perl are really just 'wrappers' around lower level system library calls of the same name. Most (gulp) modern OSes support theses calls,

      mitd-Made in the Dark
      'Interactive! Paper tape is interactive!
      If you don't believe me I can show you my paper cut scars!'

        what im realy interested is on the time() function and not
        so much on localtime(), im in editing the time()
        value before i use it in the localtime() to translate.

        To do what i want i need to understand how localtime()
        translate the time() value? to see if i can add or
        subtract to get the value that i want or date that i want!

        i know that my problem could be solved by creating a table
        that will correspond to each week number, but i would like
        to achieve this the mathematical way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://127001]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2018-05-28 04:23 GMT
Find Nodes?
    Voting Booth?