# Interesting date

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
I'm trying to compute the date  250 days ago and I get this

\$now = getdate(strtotime("now"));
\$old = getdate(strtotime("-250 days"));

and I get right now with

\$old["mon"] and \$old["mday"]

31 june. Well, that doesn't sound right.
Can you spot the error?
--
I didn't know sci.bio.paleontology was that low traffic until I tried read
the thread "Where is everyone?" and found it to be expired.

## Re: Interesting date

Here's what I gets:
\$now = Array
(
[seconds] => 36
[minutes] => 58
[hours] => 12
[mday] => 5
[wday] => 1
[mon] => 2
[year] => 2007
[yday] => 35
[weekday] => Monday
[month] => February
[0] => 1170673116
)
\$old = Array
(
[seconds] => 36
[minutes] => 58
[hours] => 12
[mday] => 31
[wday] => 3
[mon] => 5
[year] => 2006
[yday] => 150
[weekday] => Wednesday
[month] => May
[0] => 1149069516
)
Now this is just a guess, but if 'june' comes from an array starting with
zero, so that 0=january, then 4=may and 5=june, it propably should start
from 1=january and in that case 5 would actually be may... If that doesn't
help, see the whole output of getdate with print_r() and post the result
here.

--
"Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia  koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pivittyv nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)

## Re: Interesting date

How can any one start counting from something else than zero in computer
applications?

Thanks! I'm so very, very stupid.

--
I didn't know sci.bio.paleontology was that low traffic until I tried read
the thread "Where is everyone?" and found it to be expired.

## Re: Interesting date

When dates are prsented in a numeric format, like YYYY-MM-DD, the months are
1-12, not 0-11 and this is what getdate outputs. No one said it's an array
offset, it's the ordinal number of the month. Calendars were invented before
computers. ;)

I've been equally stupid once. That's how I knew what to suspect. Try
formatting dates with the php built-in function date() to avoid confusions
like that.

--
"Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia  koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pivittyv nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)

## Re: Interesting date

Laine contained the following:

I'm regularly stupid.  %-}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

## Re: Interesting date

Gunnar G wrote:

Actually, before C, most languages did start counting with 1....

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

## Re: Interesting date

On Mon, 05 Feb 2007 11:09:58 GMT, Gunnar G wrote:

Standards are GREAT.  And, you have so many to chose from!

I don't think so.  As someone who has worked his way through *A LOT* of
programming languages since 1966, "Counting from 0/1" is just _one_ of
the 'standards' I never take for granted.  (And, I _still_ screw up....)

Jonesy
--
Marvin L Jones    | jonz          | W3DHJ  | linux
38.24N  104.55W  |  @ config.com | Jonesy |  OS/2

## Re: Interesting date

Allodoxaphobia wrote:

I seem to remember that back in the C64 days you could actually tell
the script (program) to start at 0 or 1 if you wanted. I can't remember
what that command was though...

Norm

## Re: Interesting date

VB6 allowed you to put the "Option Base 1" directive at the top of a
module to achieve the same result. Scary that I remember that...

## Re: Interesting date

Gunnar G wrote:

I get \$old["mon"] as "5" -- that is, May, not June.

PHP numbers months starting with January as 1. This is different from
Perl's "time" and "gmtime" functions, which number months starting with
January as 0.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!