Re: [PHP] Validate The Last Day of Month with server's clock????
And the reason I quoted 'usual' is that my suggestion is more portable. On Thursday 14 Aug 2003 11:54 am, Ford, Mike [LSS] wrote: On 13 August 2003 20:05, Nicholas Robinson wrote: On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. Actually, the usual trick is to ask mktime() for the 0th day of the following month. One of the examples on the mktime() page of the manual (http://www.php.net/mktime) even illustrates exactly this. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validate The Last Day of Month with server's clock????
?php // check last day of september $month = '08'; $year = date(Y); $last_day = date(t, mktime (0,0,0, $month,1,$year)); print $last_day; ? -Original Message- From: Scott Fletcher [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 12:00 PM To: [EMAIL PROTECTED] Subject: [PHP] Validate The Last Day of Month with server's clock Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
From: Nicholas Robinson [EMAIL PROTECTED] The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. Along those same lines, this works: ?php $month = 12; $year = 2003; $last_day_of_month = mktime(12,0,0,$month+1,0,$year); echo date('m/d/Y',$last_day_of_month); ? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validate The Last Day of Month with server's clock????
Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
Alright, interesting thought, never thought it would be possible. So, what would the PHP script be when matching it against the clock or something? Perhap mktime(). Anyone know? Scott F. Nicholas Robinson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. HTH Nick On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
Ah! that seem nicer when just using the script ($month+1)... Cpt John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From: Nicholas Robinson [EMAIL PROTECTED] The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. Along those same lines, this works: ?php $month = 12; $year = 2003; $last_day_of_month = mktime(12,0,0,$month+1,0,$year); echo date('m/d/Y',$last_day_of_month); ? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validate The Last Day of Month with server's clock????
On 14 August 2003 16:01, Scott Fletcher wrote: Mike Ford [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 13 August 2003 20:05, Nicholas Robinson wrote: On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. Actually, the usual trick is to ask mktime() for the 0th day of the following month. One of the examples on the mktime() page of the manual (http://www.php.net/mktime) even illustrates exactly this. True but I just only want the day date, don't want the number of seconds. So use one of the other Date/Time functions to to convert it back to whatever you do want -- date(), getdate() and strftime() all accept a timestamp produced by mktime() as an optional parameter. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? If you're in unix, pull the last token from the default output of `cal`: August 2003 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validate The Last Day of Month with server's clock????
On 13 August 2003 20:05, Nicholas Robinson wrote: On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. Actually, the usual trick is to ask mktime() for the 0th day of the following month. One of the examples on the mktime() page of the manual (http://www.php.net/mktime) even illustrates exactly this. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. HTH Nick On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
True but I just only want the day date, don't want the number of seconds. Mike Ford [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 13 August 2003 20:05, Nicholas Robinson wrote: On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. Actually, the usual trick is to ask mktime() for the 0th day of the following month. One of the examples on the mktime() page of the manual (http://www.php.net/mktime) even illustrates exactly this. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validate The Last Day of Month with server's clock????
Did a lot of searching on the internet and found a simple PHP code that does the trick. How the code work is when you pick a month where you want the last day to be in, then use the next month into the PHP script to get the last day of the month you're looking for. --snip-- //Want to see the last day of Febraury (Then insert the next month to find out). echo strftime(%d, mktime(0,0,0,3,0,2004)); --snip-- Scott Fletcher [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Alright, interesting thought, never thought it would be possible. So, what would the PHP script be when matching it against the clock or something? Perhap mktime(). Anyone know? Scott F. Nicholas Robinson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The 'usual' trick is to set the date to the first day of the month after the one you want and then subtract one day. HTH Nick On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote: Hi! Here's a trick script. We know that some months have the last day which is 30 while other is 31. As for February, it can be either 28 or 29. So, what's the trick in using the php to find out what is the last day of the month if you want to checked it against the server's clock to find out the last day of the month. Suppose it is this month or 3 months ago or 3 months from now. Anyone know? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php