Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

RE: Getting the date of today as a number (was: Date question)

by Simplicus (Monk)
on Apr 20, 2000 at 04:24 UTC ( [id://8098]=note: print w/replies, xml ) Need Help??


in reply to Getting the date of today as a number (was: Date question)

The localtime(time) function returns a nine element array, the values of the array are:
   index        value
=====================
      [0]      second
      [1]      minute
      [2]        hour
      [3]   month day 
      [4]       month
      [5]        year
      [6] day of week
      [7] day of year
      [8]       isdst : not sure what this refers to . . .

There are a couple of things to watch out for in this array . . .the elements month and day are zero-based (because you'll probably use them as indexes into arrays containing month and day names . . .) and the year element has had 1900 subtracted from it, so this code:

@timearray = localtime(time); print "$timearray[5]\n"
will print 100, not 00 or 2000.
Good question!
Simplicus

Replies are listed 'Best First'.
RE: RE: Getting the date of today as a number (was: Date question)
by Simplicus (Monk) on Apr 20, 2000 at 06:47 UTC
    Sorry, but the above writeup has a couple flaws, and thanks to chromatic for setting me straight.
    First, the $isdst scalar is a flag for daylight savings time, 1 for yes, 0 for no, and negative is "unknown."
    Second, the year hasn't really had 1900 subtracted from it, it's really just the number of years since 1900.
    Thanks again to my Dodecatonic friend, chromatic. (I was a music composition major, once upon a time.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found