php-general Digest 9 Mar 2012 11:25:57 -0000 Issue 7719
php-general Digest 9 Mar 2012 11:25:57 - Issue 7719 Topics (messages 316940 through 316949): Re: Function mktime() documentation question 316940 by: Tedd Sperling 316941 by: Daniel Brown 316942 by: Jim Lucas 316943 by: Jim Lucas 316944 by: Jim Lucas 316945 by: Jim Lucas 316946 by: Tedd Sperling 316947 by: Charles 316948 by: Ford, Mike 316949 by: Lester Caine Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Mar 8, 2012, at 11:20 AM, Ford, Mike wrote: -Original Message- From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] From my code, the number of days in a month can be found by using 0 as the first index of the next month -- not the last day of the previous month. Huh? The 0th day of next month *is* the last day of the current month, which gives you the number of days in the current month. QED. I think it's possible you may be being confuzled by the number of nexts and previouses floating around. Your mktime call is asking for the 0th day of next month, i.e. the last day of the previous month of next month, i.e. the last day of the current month. Which is exactly what you say works. I think. :) However, I agree that the description is not very well worded - saying that days in the requested month are relative to the previous month is very odd indeed if you ask me -- if they must be relative to anything, why not the beginning of the relevant month? Actually, with a bit more thought, I think I'd rewrite it something like this: The day number relative to the given month. Day numbers 1 to 28, 29, 30 or 31 (depending on the month) refer to the normal days in the month. Numbers less than 1 refer to days in the previous month, so 0 is the last day of the preceding month, -1 the day before that, etc. Numbers greater than the actual number of days in the month refer to days in the following month(s). Mike: Very well put. You say: Huh? The 0th day of next month *is* the last day of the current month, which gives you the number of days in the current month. That IS exactly what I am saying. But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? It would have been better if one could use: $what_date = getdate(mktime(0, 0, 0, $this_month, 0, $year)); $days_in_this_month = $what_date['nday']; // note an additional key for getdate() But instead, we have to use: $next_month = $this_month +1; $what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year)); $days_in_this_month = $what_date['mday']; Additionally, there's a perception problem. You say that 0 of the next month *is* the last day of the current month -- as such, apparently months overlap in your (and Dan's) explanation. Well... I agree with both of you, but my objection is having to increase the month value by one to get the number of days in the current month. That's all I was saying. Side-point: I find it interesting that getdate() has all sorts of neat descriptions for the current month (such as, what weekday a numbered day is), but lacks how many days are in the month. Doesn't that seem odd? Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com ---End Message--- ---BeginMessage--- On Mar 8, 2012 6:14 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 8, 2012, at 11:20 AM, Ford, Mike wrote: -Original Message- From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] From my code, the number of days in a month can be found by using 0 as the first index of the next month -- not the last day of the previous month. Huh? The 0th day of next month *is* the last day of the current month, which gives you the number of days in the current month. QED. I think it's possible you may be being confuzled by the number of nexts and previouses floating around. Your mktime call is asking for the 0th day of next month, i.e. the last day of the previous month of next month, i.e. the last day of the current month. Which is exactly what you say works. I think. :) However, I agree that the description is not very well worded - saying that days in the requested month are relative to the previous month is very odd indeed if you ask me -- if they must be relative to anything, why not the beginning of the relevant month? Actually, with a bit more thought, I think I'd rewrite it something like this: The day number relative to the given month. Day numbers 1 to 28, 29, 30 or 31 (depending on the month) refer to the normal days in the month. Numbers less than 1 refer to days in
php-general Digest 10 Mar 2012 03:20:00 -0000 Issue 7720
php-general Digest 10 Mar 2012 03:20:00 - Issue 7720 Topics (messages 316950 through 316961): Re: Function mktime() documentation question 316950 by: Daniel Brown 316951 by: Tedd Sperling 316952 by: Charles 316953 by: Tedd Sperling 316954 by: Charles 316955 by: Andrew Ballard 316956 by: Charles 316957 by: Ashley Sheridan 316958 by: Charles 316959 by: Tedd Sperling Re: questions about $_SERVER 316960 by: tamouse mailing lists 316961 by: Jim Giner Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- (To the list, as well. First day with my new fingers, apparently) On Fri, Mar 9, 2012 at 08:09, Daniel Brown danbr...@php.net wrote: On Thu, Mar 8, 2012 at 21:23, Tedd Sperling tedd.sperl...@gmail.com wrote: This starts getting a bit off-topic from your original email, but knowing that you're trying to use it for teaching your classes at the college, it may be of some value to you. All of this aside, though, you may instead want to use something along the lines of date('d',strtotime('last day of this month')); in tandem with your date formatting. That's a good idea, but date('d',strtotime('last day of this month')); gives me the number of days in *this* month, but not the next, or previous, month. I need the result to be whatever date was selected -- something like: $number_days = date('d',strtotime('last day of April, 2014')); But that doesn't work. Sure it does, though you may have some issues when using punctuation, unnecessary words, or using capital letters for anything other than proper names. What version of PHP are you using? I get the correct answers for all of the following phrases: last day of April 2014 last day of this month last day of next month last day of last month third Saturday March 2012 Or you can even be excruciatingly redundant: echo date('d',strtotime('last day of this month',strtotime('next month'))); echo date('d',strtotime('last day of this month',strtotime('February 2018'))); echo date('d',strtotime('second Monday',strtotime('September 2012'))); -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ ---End Message--- ---BeginMessage--- On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. I like things to be self-contained. For the exception of multiverse arguments, everything should be self evident. But instead, we have to use: $next_month = $this_month +1; $what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year)); $days_in_this_month = $what_date['mday']; To me, that's a clever and elegant solution. It's clear that our brains just work differently on this one. We all have differences in perception, how we analyze problems, and how we create solutions -- and that's a good thing. Side-point: I find it interesting that getdate() has all sorts of neat descriptions for the current month (such as, what weekday a numbered day is), but lacks how many days are in the month. Doesn't that seem odd? Now that's a decent point: I can see where you're coming from with that one. I don't know what performance penalty there might be (if any) to calculate that for every call to getdate(), but it certainly seems like a reasonable feature request. I'm glad I have a decent point somewhere in this exchange and that we agree on something. :-) Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com ---End Message--- ---BeginMessage--- On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to
RE: [PHP] Function mktime() documentation question
-Original Message- From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] Sent: 08 March 2012 23:15 To: PHP-General List [previous discussion snipped] Mike: Very well put. You say: Huh? The 0th day of next month *is* the last day of the current month, which gives you the number of days in the current month. That IS exactly what I am saying. But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) It would have been better if one could use: $what_date = getdate(mktime(0, 0, 0, $this_month, 0, $year)); $days_in_this_month = $what_date['nday']; // note an additional key for getdate() But that $what_date would still refer to a day in *last* month! (Which isn't going to change, as it would be a significant BC break.) But instead, we have to use: $next_month = $this_month +1; $what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year)); $days_in_this_month = $what_date['mday']; To me, that's a clever and elegant solution. It's clear that our brains just work differently on this one. Additionally, there's a perception problem. You say that 0 of the next month *is* the last day of the current month -- as such, apparently months overlap in your (and Dan's) explanation. Well... I agree with both of you, but my objection is having to increase the month value by one to get the number of days in the current month. Not overlap as such, I don't think -- there's just a continuum such that the 0th of a month is the day before the 1st (and hence the last day of the preceding month!), the -1th is the day before that and so on; likewise, the 32nd is the day after the 31st, and so on. Side-point: I find it interesting that getdate() has all sorts of neat descriptions for the current month (such as, what weekday a numbered day is), but lacks how many days are in the month. Doesn't that seem odd? Now that's a decent point: I can see where you're coming from with that one. I don't know what performance penalty there might be (if any) to calculate that for every call to getdate(), but it certainly seems like a reasonable feature request. (And, actually, I think we should be quite grateful that mktime() *does* take out-of-range values and do appropriate things with them -- if it didn't, I suspect the only way to do this job might be a loop similar to the one posted by Tedd, but adding chunks of 86400 to a raw timestamp. Now that really would be a bit obscure!!!) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
Ford, Mike wrote: Side-point: I find it interesting that getdate() has all sorts of neat descriptions for the current month (such as, what weekday a numbered day is), but lacks how many days are in the month. Doesn't that seem odd? Now that's a decent point: I can see where you're coming from with that one. I don't know what performance penalty there might be (if any) to calculate that for every call to getdate(), but it certainly seems like a reasonable feature request. I've never had this problem ;) http://phplens.com/phpeverywhere/adodb_date_library -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
(To the list, as well. First day with my new fingers, apparently) On Fri, Mar 9, 2012 at 08:09, Daniel Brown danbr...@php.net wrote: On Thu, Mar 8, 2012 at 21:23, Tedd Sperling tedd.sperl...@gmail.com wrote: This starts getting a bit off-topic from your original email, but knowing that you're trying to use it for teaching your classes at the college, it may be of some value to you. All of this aside, though, you may instead want to use something along the lines of date('d',strtotime('last day of this month')); in tandem with your date formatting. That's a good idea, but date('d',strtotime('last day of this month')); gives me the number of days in *this* month, but not the next, or previous, month. I need the result to be whatever date was selected -- something like: $number_days = date('d',strtotime('last day of April, 2014')); But that doesn't work. Sure it does, though you may have some issues when using punctuation, unnecessary words, or using capital letters for anything other than proper names. What version of PHP are you using? I get the correct answers for all of the following phrases: last day of April 2014 last day of this month last day of next month last day of last month third Saturday March 2012 Or you can even be excruciatingly redundant: echo date('d',strtotime('last day of this month',strtotime('next month'))); echo date('d',strtotime('last day of this month',strtotime('February 2018'))); echo date('d',strtotime('second Monday',strtotime('September 2012'))); -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. I like things to be self-contained. For the exception of multiverse arguments, everything should be self evident. But instead, we have to use: $next_month = $this_month +1; $what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year)); $days_in_this_month = $what_date['mday']; To me, that's a clever and elegant solution. It's clear that our brains just work differently on this one. We all have differences in perception, how we analyze problems, and how we create solutions -- and that's a good thing. Side-point: I find it interesting that getdate() has all sorts of neat descriptions for the current month (such as, what weekday a numbered day is), but lacks how many days are in the month. Doesn't that seem odd? Now that's a decent point: I can see where you're coming from with that one. I don't know what performance penalty there might be (if any) to calculate that for every call to getdate(), but it certainly seems like a reasonable feature request. I'm glad I have a decent point somewhere in this exchange and that we agree on something. :-) Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. The number of days in each month is fixed, except for february. If that's what you want, why don't make a table of the number of days in each month, and check for the special case of leap year. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Mar 9, 2012, at 11:17 AM, Charles wrote: On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. The number of days in each month is fixed, except for february. If that's what you want, why don't make a table of the number of days in each month, and check for the special case of leap year. No offense, but that's not the point. A look-up table would work, but why when there are all sorts of built-in functions that will? I am just looking for one that is easy to explain to students. Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Sat, Mar 10, 2012 at 12:07 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 11:17 AM, Charles wrote: On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. The number of days in each month is fixed, except for february. If that's what you want, why don't make a table of the number of days in each month, and check for the special case of leap year. No offense, but that's not the point. A look-up table would work, but why when there are all sorts of built-in functions that will? You just said yourself that I don't need to know the first day of next month to know the last day of this month, and AFAIK there is no such function in PHP to get the number of days without accessing the last second in the month. Besides, showing how it is done is part of education. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Function mktime() documentation question
And again to the list, since for some reason Reply-to-all did not do as intended this time. -- Forwarded message -- From: Andrew Ballard aball...@gmail.com Date: Fri, Mar 9, 2012 at 12:53 PM Subject: Re: [PHP] Function mktime() documentation question To: Tedd Sperling tedd.sperl...@gmail.com On Fri, Mar 9, 2012 at 12:07 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: [snip] I am just looking for one that is easy to explain to students. Cheers, tedd tedd, Since you are teaching this to students, I would recommend sticking with the internal date functions and avoiding any solution that includes adding or subtracting multiples of the magic number 86400.* Many such solutions fail to take into consideration Daylight Saving Time and are therefore guaranteed to be wrong at least twice a year (if not several months out of the year). Sure, you can write your code to handle the differences correctly, but since the rules governing the time shift are mostly arbitrary and differ across time zones the world over, it seems safer to me to rely on the internal functions when working with dates. Andrew * Even if the internal functions base their calculations on the number of seconds per day, they have at least already handled all the varied time zones and DST rules and been tested in environments all over the world. When those rules change, the internal functions will be adjusted to reflect the changes and should be much more reliable than thousands of instances of multiple strategies that get copied and pasted into projects. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Sat, Mar 10, 2012 at 12:52 AM, Charles peac...@gmail.com wrote: On Sat, Mar 10, 2012 at 12:07 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 11:17 AM, Charles wrote: On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. The number of days in each month is fixed, except for february. If that's what you want, why don't make a table of the number of days in each month, and check for the special case of leap year. No offense, but that's not the point. A look-up table would work, but why when there are all sorts of built-in functions that will? You just said yourself that I don't need to know the first day of next month to know the last day of this month, and AFAIK there is no such function in PHP to get the number of days without accessing the last second in the month. Besides, showing how it is done is part of education. Unless, of course you install the calendar extension, of which it will provides just the required function http://php.net/manual/en/function.cal-days-in-month.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
Charles peac...@gmail.com wrote: On Sat, Mar 10, 2012 at 12:52 AM, Charles peac...@gmail.com wrote: On Sat, Mar 10, 2012 at 12:07 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 11:17 AM, Charles wrote: On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. The number of days in each month is fixed, except for february. If that's what you want, why don't make a table of the number of days in each month, and check for the special case of leap year. No offense, but that's not the point. A look-up table would work, but why when there are all sorts of built-in functions that will? You just said yourself that I don't need to know the first day of next month to know the last day of this month, and AFAIK there is no such function in PHP to get the number of days without accessing the last second in the month. Besides, showing how it is done is part of education. Unless, of course you install the calendar extension, of which it will provides just the required function http://php.net/manual/en/function.cal-days-in-month.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What about just doing this: intval(date(t)); And you can pass in an argument to date() if you need a specific month. Thanks, Ash http://ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Sat, Mar 10, 2012 at 12:57 AM, Charles peac...@gmail.com wrote: On Sat, Mar 10, 2012 at 12:52 AM, Charles peac...@gmail.com wrote: On Sat, Mar 10, 2012 at 12:07 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 11:17 AM, Charles wrote: On Fri, Mar 9, 2012 at 10:58 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Mar 9, 2012, at 5:37 AM, Ford, Mike wrote: From: Tedd Sperling [mailto:tedd.sperl...@gmail.com] But why does anyone have to use the next month to figure out how many days there are are in this month? Do you see my point? Actually, no. To figure this out, somewhere along the line you've got to know where the last day of this month / first day of next month boundary lies, so I don't see how you can ever find the number of days in a month without bringing the start of next month into it somehow. (Even if it's implicitly be getting someone else's clever code to figure out 'last day of this month'!) Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. The number of days in each month is fixed, except for february. If that's what you want, why don't make a table of the number of days in each month, and check for the special case of leap year. No offense, but that's not the point. A look-up table would work, but why when there are all sorts of built-in functions that will? You just said yourself that I don't need to know the first day of next month to know the last day of this month, and AFAIK there is no such function in PHP to get the number of days without accessing the last second in the month. Besides, showing how it is done is part of education. Unless, of course you install the calendar extension, of which it will provides just the required function http://php.net/manual/en/function.cal-days-in-month.php Okay, scratch that, the standard function works fine $number_of_days = idate('t', strtotime($year.'-'.$month)); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Function mktime() documentation question
On Mar 9, 2012, at 12:52 PM, Charles wrote: On Sat, Mar 10, 2012 at 12:07 AM, Tedd Sperling tedd.sperl...@gmail.com wrote: Well no, I don't need to know the first day of next month to know the last day of this month. That's like saying I need to know who is going to stand at the 'end of the line' NEXT before I can tell who is standing at the 'end of the' line NOW. You just said yourself that I don't need to know the first day of next month to know the last day of this month, and AFAIK there is no such function in PHP to get the number of days without accessing the last second in the month. Besides, showing how it is done is part of education. Arrggg. When I said I, I meant I and not a php function. Sometimes the point is never made. tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about $_SERVER
On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote: On 13 Feb 2012, at 06:28, Rui Hu wrote: How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know if I want to modify $_SERVER myself? Once your script starts the superglobals are no different to any other variables, except that they're in scope at all times. That's probably the reason why they are named SuperGlobals. :-) But to be more descriptive, these are simply globals that are predefined by php -- see: http://php.net/manual/en/language.variables.superglobals.php I believe, (please show me otherwise) there are no globals in PHP other than SuperGlobals. Assuming you mean pre-defined ones, there shouldn't be, since no other ones are documented. If there are, then either they should be documented, or they should be ignored as it can be dangerous to use undocumented features. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions about $_SERVER
tamouse mailing lists tamouse.li...@gmail.com wrote in message news:CAHUC_t8g43GE3xqvSU5SwFePGS1XG=tk1mhrbem9gjaarve...@mail.gmail.com... On Mon, Feb 13, 2012 at 2:39 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote: On 13 Feb 2012, at 06:28, Rui Hu wrote: How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know if I want to modify $_SERVER myself? Once your script starts the superglobals are no different to any other variables, except that they're in scope at all times. That's probably the reason why they are named SuperGlobals. :-) But to be more descriptive, these are simply globals that are predefined by php -- see: http://php.net/manual/en/language.variables.superglobals.php I believe, (please show me otherwise) there are no globals in PHP other than SuperGlobals. Assuming you mean pre-defined ones, there shouldn't be, since no other ones are documented. If there are, then either they should be documented, or they should be ignored as it can be dangerous to use undocumented features. :) Just to be clear - you asked if it were true that there are no globals in PHP other than SuperGlobals: Don't forget that anything that you declare as global in a script is a global for that instance of that script (and whatever includes, etc. that it calls during its run) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php