Re: Date Issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-11-18 at 10:11 -0500, Andrew Ballard wrote:
> On Mon, Nov 17, 2008 at 6:02 PM, Ashley Sheridan
> <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> > On Mon, 2008-11-17 at 16:57 -0600, Boyd, Todd M. wrote:
> >> > -----Original Message-----
> >> > From: Craige Leeder [mailto:cleeder@xxxxxxxxx]
> >> > Sent: Monday, November 17, 2008 4:50 PM
> >> > To: Boyd, Todd M.
> >> > Cc: admin@xxxxxxxxxxxxxxxxxxx; php-general@xxxxxxxxxxxxx
> >> > Subject: Re:  Date Issue
> >> >
> >> > Boyd, Todd M. wrote:
> >> > >> Are you sure this isn't like Javascript's "getMonth" function? Its
> >> > index may begin at 0, making "day 0" the "first day" of the year.
> >> > >>
> >> > Hmm, though I know us programmers love to start counting at zero, why
> >> > would something as static as a date start counting at zero? I would
> >> > have
> >> > imagined something like that would start at 1.
> >>
> >> I dunno. Threw me for a hell of a loop (no pun intended) when I first started playing with Javascript dates, though. Year = starts at 1 (not literally, but for all intents and purposes). Day = starts at 1. Month = starts at 0? What?! :)
> >>
> >>
> >> // Todd
> > It makes no sense does it?! I was lucky enough to have an Oreilly book
> > with me at the time I was learning javascript. Only book of theirs i
> > wasnt so hot on was an ajax one.
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> 
> I suspect it was done because it allows people to work with arrays for
> month names (including the options array that is part of the
> Javascript objects that represent SELECT tags) without having to
> subtract one from the index each time it gets used. In that sense, I
> can see the reasoning of why months and days of the week work that way
> (even though I think it's counter-intuitive and subtraction is a
> pretty simple operation).
> 
> I don't understand why the day of the month or of the year would be
> zero-based, though. It's almost like the function just takes the
> number of seconds elapsed since the beginning of the year, divides by
> 86400 and truncates the result to a integer.
> 
> Andrew
It just flew in the face of all I knew at the time to have a
non-associative system-generated array (by that I mean one whos keys are
integars and not string keys) that doesn't start at 0. No other arrays
defined in Javascript that I'm aware of behave like this, not even the
DOM ones.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux