Re: [PHP] Date Issue

2008-11-18 Thread Andrew Ballard
On Tue, Nov 18, 2008 at 2:58 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:
> 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

That's what I'm talking about. Those functions like javascript's
getMonth() return an int that is one less than the month number. My
assumption is that people who defined the language made it this way so
that you can write code that uses non-associative, zero-based arrays
to decode the month number to a string:

var month_names['en'] = new Array('January', 'February', 'March',
'April', 'May', 'June', 'July', 'August', 'September', 'October',
'November', 'December');
var myDate = new Date();
var x = month_names['en'][myDate.getMonth()];


If getMonth() wasn't zero-based, you'd either have to include an empty
element in the 0th position of at the beginning of the array, use an
associative array, or that last line would have to be changed:

var x = month_name['en'][myDate.getMonth() - 1]'

Andrew

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



Re: [PHP] Date Issue

2008-11-18 Thread Ashley Sheridan
On Tue, 2008-11-18 at 10:11 -0500, Andrew Ballard wrote:
> On Mon, Nov 17, 2008 at 6:02 PM, Ashley Sheridan
> <[EMAIL PROTECTED]> wrote:
> > On Mon, 2008-11-17 at 16:57 -0600, Boyd, Todd M. wrote:
> >> > -Original Message-
> >> > From: Craige Leeder [mailto:[EMAIL PROTECTED]
> >> > Sent: Monday, November 17, 2008 4:50 PM
> >> > To: Boyd, Todd M.
> >> > Cc: [EMAIL PROTECTED]; php-general@lists.php.net
> >> > Subject: Re: [PHP] 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



Re: [PHP] Date Issue

2008-11-18 Thread Andrew Ballard
On Mon, Nov 17, 2008 at 6:02 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:
> On Mon, 2008-11-17 at 16:57 -0600, Boyd, Todd M. wrote:
>> > -Original Message-
>> > From: Craige Leeder [mailto:[EMAIL PROTECTED]
>> > Sent: Monday, November 17, 2008 4:50 PM
>> > To: Boyd, Todd M.
>> > Cc: [EMAIL PROTECTED]; php-general@lists.php.net
>> > Subject: Re: [PHP] 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

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



RE: [PHP] Date Issue

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 16:57 -0600, Boyd, Todd M. wrote:
> > -Original Message-
> > From: Craige Leeder [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 17, 2008 4:50 PM
> > To: Boyd, Todd M.
> > Cc: [EMAIL PROTECTED]; php-general@lists.php.net
> > Subject: Re: [PHP] 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


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



RE: [PHP] Date Issue

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: Craige Leeder [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2008 4:50 PM
> To: Boyd, Todd M.
> Cc: [EMAIL PROTECTED]; php-general@lists.php.net
> Subject: Re: [PHP] 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


Re: [PHP] Date Issue

2008-11-17 Thread Craige Leeder

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.

HTH,


Todd Boyd
Web Programmer

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.


Guess it's just me.
- Craige

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



Re: [PHP] Date Issue

2008-11-17 Thread Nathan Rixham

Boyd, Todd M. wrote:

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 10:50 AM
To: php-general@lists.php.net
Subject: [PHP] Date Issue

$smont = 10;
$sday = 13;
$syear = 2008;
$timestamp = mktime(0,0,0,$smont,$sday,$syear);
$thismonth = getdate($timestamp);

Here is where the problem comes into play.

echo $thismonth['yday'];

This displays 286 when in fact its 287.
Is there a problem in my ini file or what is the deal.


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.

HTH,


Todd Boyd
Web Programmer


yup..



(it is a leap year)
so recap: yday 0 = 1st jan

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



RE: [PHP] Date Issue

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2008 10:50 AM
> To: php-general@lists.php.net
> Subject: [PHP] Date Issue
> 
> $smont = 10;
> $sday = 13;
> $syear = 2008;
> $timestamp = mktime(0,0,0,$smont,$sday,$syear);
> $thismonth = getdate($timestamp);
> 
> Here is where the problem comes into play.
> 
> echo $thismonth['yday'];
> 
> This displays 286 when in fact its 287.
> Is there a problem in my ini file or what is the deal.

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.

HTH,


Todd Boyd
Web Programmer


[PHP] Date Issue

2008-11-17 Thread admin
$smont = 10;
$sday = 13;
$syear = 2008;
$timestamp = mktime(0,0,0,$smont,$sday,$syear);
$thismonth = getdate($timestamp);

Here is where the problem comes into play.

echo $thismonth['yday'];

This displays 286 when in fact its 287.
Is there a problem in my ini file or what is the deal.

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



Re: [PHP] Date Issue

2008-04-01 Thread Richard Lynch
If you want the DAY before, you can use the -1 for the day, and get
what you want.

mktime() will "wrap" the month as needed.

But, yeah, if you try to hit a MONTH before by putting in a month
before AND the day, it will "slingshot" back and forth to get what you
don't want.

If you want the MONTH before, I *suspect* you can use date('m') for
the argument, and do NOT provide a day, and it may do what you want.

But for sure, if you use ONE (1) for the day, and then -1 for the
month it will do what you want, since every month has a ONE (1) day.

Anything 1 from 28 will work fine, actually, but using 1 is probably
clearest:

$today = mktime();
$tomorrow = mktime(1, 0, 0, date('m'), date('d') + 1);
$next_month = mktime(1, 0, 0, date('m') + 1, 1);
$last_month = mktime(1, 0, 0, date('m') - 1, 1);

I've been using these for a web calendar since nineteen-ninety-mumble,
and they've worked fine, through leap years.

You can view the source to the PDF version here:
http://uncommonground.com/events.phps

The HTML version has the exact same stuff at the top.
http://uncommonground.com/events.htm

Feel free to page through as many months/years past/present and future
to see that it works.

Since it's a 32-bit machine, it does conk out in March 2038.

I'm fairly confident our web-server will be a 64-bit machine before we
book any (real) events for 2038...

You can ignore my test events in January 2038 :-)

On Mon, March 31, 2008 3:24 pm, [EMAIL PROTECTED] wrote:
> Thank you again Dan. Thought never crossed my mind the day being the
> 31st. That fixed it.
>
> Richard L. Buskirk
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Mon, Mar 31, 2008 at 4:15 PM,  <[EMAIL PROTECTED]> wrote:
>> I tried that a big no go.
>>  Seems if I do a +1 i get 2 months from now and a -1 gives me the
>> current
> month.
>>
>>
>>
>>  $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
>>  $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"),
>> date("Y")));
>>  $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>>
>>
>>  $month echo's MARCH should be Feb
>>  $zomonth echo's MARCH should be March
>>  $nmonth echo's MAY this should be April
>
> That's because you're using today's date('d');, which is 31.
>
> February doesn't have 31 days, nor does April, so mktime() forces
> them to the following month to correct the error.
>
> --
> 
> Forensic Services, Senior Unix Engineer
> 1+ (570-) 362-0283
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date Issue

2008-04-01 Thread admin
Your doing the same thing i did look at date(d)

When its the 31 like yesteday of course it can not find the 31 of months that 
do not have them. 
Thats why it errored. 


String worked up till monday which explained alot. I just did not look at what 
i was doing. changed the code to 


$zomonth = date("F", mktime(0,0,0, date("m")-1, 1, date('Y')));
works perfect 
thanks to dan who pointed out the lack of sleep in me :)














I generally use 1 hour after midnight with mktime() to avoid the edge
cases of daylight savings etc...

mktime(1, 0, 0, date('m') - 1, date('d'), date('Y'));

You also have to consider that you *COULD* call this right on the cusp
of midnight, and the call to date('d') could happen one day, and the
call to mktime( ) the next "day" as the clock ticked over...

At 1 am, the day doesn't change over...

Larry's probably right that you should use DateTime, but it's too
new-fangled for an old fart like me to have got around to messing with
it yet...

On Mon, March 31, 2008 3:15 pm, [EMAIL PROTECTED] wrote:
> I tried that a big no go.
> Seems if I do a +1 i get 2 months from now and a -1 gives me the
> current month.
>
>
> $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
> $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"),
> date("Y")));
> $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
> $month echo's MARCH should be Feb
> $zomonth echo's MARCH should be March
> $nmonth echo's MAY this should be April
>
> You will notice i used all options apostrophes double quotes and no
> quotes exactly the same output.
>
>
>
>
>
>
>
> You need apostrophes (or quotes) around your args to date() in the
> parameters...
>
> date('m')
>
> As it stands now, PHP assumes you mean the constant m
> (http://php.net/define) and that's not defined, so they are all 0.
>
> So you are passing in 0 to ALL the args.
>
> You also should use E_ALL for your error_reporting so you would SEE
> the error messages telling you about this.
>
> On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
>> Not understanding why this is happening.
>>
>> $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
>> $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>>
>> echoing out the exact same month
>> March
>> March
>>
>> Checked server timezone/date/time all is good. Am I half asleep at
>> the
>> wheel on this one and just not seeing my mistake here?
>>
>>
>> Richard L. Buskirk
>>
>> Hardware Failure: $4,000.
>> Network Outage: $15,000.
>> Always blaming the programmers for everything: Priceless.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Date Issue

2008-04-01 Thread Richard Lynch
I generally use 1 hour after midnight with mktime() to avoid the edge
cases of daylight savings etc...

mktime(1, 0, 0, date('m') - 1, date('d'), date('Y'));

You also have to consider that you *COULD* call this right on the cusp
of midnight, and the call to date('d') could happen one day, and the
call to mktime( ) the next "day" as the clock ticked over...

At 1 am, the day doesn't change over...

Larry's probably right that you should use DateTime, but it's too
new-fangled for an old fart like me to have got around to messing with
it yet...

On Mon, March 31, 2008 3:15 pm, [EMAIL PROTECTED] wrote:
> I tried that a big no go.
> Seems if I do a +1 i get 2 months from now and a -1 gives me the
> current month.
>
>
> $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
> $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"),
> date("Y")));
> $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
> $month echo's MARCH should be Feb
> $zomonth echo's MARCH should be March
> $nmonth echo's MAY this should be April
>
> You will notice i used all options apostrophes double quotes and no
> quotes exactly the same output.
>
>
>
>
>
>
>
> You need apostrophes (or quotes) around your args to date() in the
> parameters...
>
> date('m')
>
> As it stands now, PHP assumes you mean the constant m
> (http://php.net/define) and that's not defined, so they are all 0.
>
> So you are passing in 0 to ALL the args.
>
> You also should use E_ALL for your error_reporting so you would SEE
> the error messages telling you about this.
>
> On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
>> Not understanding why this is happening.
>>
>> $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
>> $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>>
>> echoing out the exact same month
>> March
>> March
>>
>> Checked server timezone/date/time all is good. Am I half asleep at
>> the
>> wheel on this one and just not seeing my mistake here?
>>
>>
>> Richard L. Buskirk
>>
>> Hardware Failure: $4,000.
>> Network Outage: $15,000.
>> Always blaming the programmers for everything: Priceless.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date Issue

2008-03-31 Thread Daniel Brown
On Mon, Mar 31, 2008 at 4:24 PM,  <[EMAIL PROTECTED]> wrote:
> Thank you again Dan. Thought never crossed my mind the day being the 31st. 
> That fixed it.

Thank Andrew Ballard, actually.  He said it even before I did.

I'm getting slow in my old age!  ;-P

-- 

Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] Date Issue

2008-03-31 Thread Andrew Ballard
On Mon, Mar 31, 2008 at 4:15 PM,  <[EMAIL PROTECTED]> wrote:
> I tried that a big no go.
>  Seems if I do a +1 i get 2 months from now and a -1 gives me the current 
> month.
>
>
>  $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
>  $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"), date("Y")));
>  $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
>  $month echo's MARCH should be Feb
>  $zomonth echo's MARCH should be March
>  $nmonth echo's MAY this should be April
>
>  You will notice i used all options apostrophes double quotes and no quotes 
> exactly the same output.
>
>
>
>
>
>
>
>  You need apostrophes (or quotes) around your args to date() in the
>  parameters...
>
>  date('m')
>
>  As it stands now, PHP assumes you mean the constant m
>  (http://php.net/define) and that's not defined, so they are all 0.
>
>  So you are passing in 0 to ALL the args.
>
>  You also should use E_ALL for your error_reporting so you would SEE
>  the error messages telling you about this.
>

Just to clarify -- Richard's response fixes a poor coding practice in
your original post, but it does not "fix" the problem that you
originally asked about.

Andrew

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



Re: [PHP] Date Issue

2008-03-31 Thread admin
Thank you again Dan. Thought never crossed my mind the day being the 31st. That 
fixed it. 

Richard L. Buskirk














On Mon, Mar 31, 2008 at 4:15 PM,  <[EMAIL PROTECTED]> wrote:
> I tried that a big no go.
>  Seems if I do a +1 i get 2 months from now and a -1 gives me the current 
month.
>
>
>
>  $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
>  $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"), date("Y")));
>  $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
>  $month echo's MARCH should be Feb
>  $zomonth echo's MARCH should be March
>  $nmonth echo's MAY this should be April

That's because you're using today's date('d');, which is 31.

February doesn't have 31 days, nor does April, so mktime() forces
them to the following month to correct the error.

-- 

Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] Date Issue

2008-03-31 Thread Andrew Ballard
On Mon, Mar 31, 2008 at 4:15 PM,  <[EMAIL PROTECTED]> wrote:
> I tried that a big no go.
>  Seems if I do a +1 i get 2 months from now and a -1 gives me the current 
> month.

Like I said, mktime makes corrections for otherwise invalid dates.
Today is March 31. Moving the month number back by one (-1) creates a
timestamp for February 31, which gets corrected to become March 2
(March 3 in non-leap years). Moving the month number ahead by one (+1)
creates a timestamp for April 31 gets corrected to become May 1.

Andrew

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



Re: [PHP] Date Issue

2008-03-31 Thread Dan Joseph
On Mon, Mar 31, 2008 at 3:15 PM, <[EMAIL PROTECTED]> wrote:

> I tried that a big no go.
> Seems if I do a +1 i get 2 months from now and a -1 gives me the current
> month.
>
>
> $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
> $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"), date("Y")));
> $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
> $month echo's MARCH should be Feb
> $zomonth echo's MARCH should be March
> $nmonth echo's MAY this should be April
>
> You will notice i used all options apostrophes double quotes and no quotes
> exactly the same output.
>
>
>
>
>
>
>
> You need apostrophes (or quotes) around your args to date() in the
> parameters...
>
> date('m')
>
> As it stands now, PHP assumes you mean the constant m
> (http://php.net/define) and that's not defined, so they are all 0.
>
> So you are passing in 0 to ALL the args.
>
> You also should use E_ALL for your error_reporting so you would SEE
> the error messages telling you about this.
>
> On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
> > Not understanding why this is happening.
> >
> > $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
> > $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
> >
> > echoing out the exact same month
> > March
> > March
> >
> > Checked server timezone/date/time all is good. Am I half asleep at the
> > wheel on this one and just not seeing my mistake here?
> >
> >
> > Richard L. Buskirk
> >
> > Hardware Failure: $4,000.
> > Network Outage: $15,000.
> > Always blaming the programmers for everything: Priceless.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Well, to re-iterate what Andrew said, you're on the 31st day of the month.
Feb 31st translates to March, April 31st translates to May.

-- 
-Dan Joseph

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] Date Issue

2008-03-31 Thread Daniel Brown
On Mon, Mar 31, 2008 at 4:15 PM,  <[EMAIL PROTECTED]> wrote:
> I tried that a big no go.
>  Seems if I do a +1 i get 2 months from now and a -1 gives me the current 
> month.
>
>
>
>  $month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
>  $zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"), date("Y")));
>  $nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));
>
>
>  $month echo's MARCH should be Feb
>  $zomonth echo's MARCH should be March
>  $nmonth echo's MAY this should be April

That's because you're using today's date('d');, which is 31.

February doesn't have 31 days, nor does April, so mktime() forces
them to the following month to correct the error.

-- 

Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

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



Re: [PHP] Date Issue

2008-03-31 Thread admin
I tried that a big no go.
Seems if I do a +1 i get 2 months from now and a -1 gives me the current month.


$month = date("F", mktime(0,0,0, date('m'), date('d'), date('Y')));
$zomonth = date("F", mktime(0,0,0, date("m")-1, date("d"), date("Y")));
$nmonth = date("F", mktime(0,0,0, date(m)+1, date(d), date("Y")));


$month echo's MARCH should be Feb
$zomonth echo's MARCH should be March
$nmonth echo's MAY this should be April

You will notice i used all options apostrophes double quotes and no quotes 
exactly the same output.







You need apostrophes (or quotes) around your args to date() in the
parameters...

date('m')

As it stands now, PHP assumes you mean the constant m
(http://php.net/define) and that's not defined, so they are all 0.

So you are passing in 0 to ALL the args.

You also should use E_ALL for your error_reporting so you would SEE
the error messages telling you about this.

On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
> Not understanding why this is happening.
>
> $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
> $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>
> echoing out the exact same month
> March
> March
>
> Checked server timezone/date/time all is good. Am I half asleep at the
> wheel on this one and just not seeing my mistake here?
>
>
> Richard L. Buskirk
>
> Hardware Failure: $4,000.
> Network Outage: $15,000.
> Always blaming the programmers for everything: Priceless.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Date Issue

2008-03-31 Thread Richard Lynch
You need apostrophes (or quotes) around your args to date() in the
parameters...

date('m')

As it stands now, PHP assumes you mean the constant m
(http://php.net/define) and that's not defined, so they are all 0.

So you are passing in 0 to ALL the args.

You also should use E_ALL for your error_reporting so you would SEE
the error messages telling you about this.

On Mon, March 31, 2008 2:07 pm, [EMAIL PROTECTED] wrote:
> Not understanding why this is happening.
>
> $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
> $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>
> echoing out the exact same month
> March
> March
>
> Checked server timezone/date/time all is good. Am I half asleep at the
> wheel on this one and just not seeing my mistake here?
>
>
> Richard L. Buskirk
>
> Hardware Failure: $4,000.
> Network Outage: $15,000.
> Always blaming the programmers for everything: Priceless.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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



Re: [PHP] Date Issue

2008-03-31 Thread Andrew Ballard
On Mon, Mar 31, 2008 at 3:07 PM,  <[EMAIL PROTECTED]> wrote:
> Not understanding why this is happening.
>
>  $month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
>  $zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));
>
>  echoing out the exact same month
>  March
>  March
>
>  Checked server timezone/date/time all is good. Am I half asleep at the wheel 
> on this one and just not seeing my mistake here?

mktime "will automatically calculate the correct value for out-of-range input."

The "31st day of February in 2008" is March 2nd, so both dates are in March.

Andrew

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



[PHP] Date Issue

2008-03-31 Thread admin
Not understanding why this is happening.

$month = date("F", mktime(0,0,0, date(m), date(d), date(Y)));
$zomonth = date("F", mktime(0,0,0, date(m)-1, date(d), date(Y)));

echoing out the exact same month
March 
March

Checked server timezone/date/time all is good. Am I half asleep at the wheel on 
this one and just not seeing my mistake here?


Richard L. Buskirk

Hardware Failure: $4,000.
Network Outage: $15,000.
Always blaming the programmers for everything: Priceless.

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