Re: [PHP] Date Issue

This is a discussion on Re: [PHP] Date Issue within the PHP General forums, part of the PHP Programming Forums category; Your doing the same thing i did look at date(d) When its the 31 like yesteday of course it ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-01-2008
admin@buskirkgraphics.com
 
Posts: n/a
Default Re: [PHP] Date Issue

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, admin@buskirkgraphics.com 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, admin@buskirkgraphics.com 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?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:52 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0