Re: [PHP] date list

2001-05-02 Thread James Holloway

Jon,

Try this ...  I know the code could be trimmed down, but I wrote it this way
for ease of reading.

select name=Date
?

$startday = 01;
$startmonth = 01;
$staryear = 01;

$endday = 01;
$endmonth = 07;
$endyear = 01;

$startperiod = mktime(0,0,0,$startmonth,$startday,$startyear);
$endperiod = mktime(0,0,0,$endmonth,$endday,$endyear);

while($startperiod = $endperiod) {

 $date = getdate($startperiod);
 $year = $date['year'];
 $month =  $date['mon'];
 $day =  $date['mday'];

 echo option value=\$year-$month-$day\;
 echo $month/$day/$year;
 echo /option\n;

 $startperiod = $startperiod + 86400;

}
?
/select

Basically just uses mktime() and getdate()

The 86400 is the number of seconds in the day, and the option value is set
to return in the format -MM-DD (that format's used a lot in MySQL
tables).

Have fun ;)

James.

 01/01/01-01/07/01
 01/08/01-01/14/01
 01/15/01-01/21/01
 etc
 etc
 till the end of 2002 and further in the future eventually

 I'd like to make PHP generate this for me so I don't have to handcode it
for
 each year in the future.  I've looked at the date/time functions and I'm a
 bit confused.  Any help would be appreciated.  Thanks!

 Jon


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] date list

2001-05-01 Thread Jon Rosenberg

I need to make a select list for a web page in the following format:

01/01/01-01/07/01
01/08/01-01/14/01
01/15/01-01/21/01
etc
etc
till the end of 2002 and further in the future eventually

I'd like to make PHP generate this for me so I don't have to handcode it for
each year in the future.  I've looked at the date/time functions and I'm a
bit confused.  Any help would be appreciated.  Thanks!

Jon


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date list

2001-05-01 Thread Chris Fry

Jon,

Just had to do almost exactly this - here's one solution. The tricky bit was
getting the number of days in the month - you have to look at next month!

This generates a list for 12 months starting with the current month and outputs
display stuff as well. In our scenario this is passed to a script which grabs
records from a database and produces a report for the month selected and the
previous month so the range of values is always for 2 months. Ours goes
backwards - you'll need to adjust it to run forwards.

  select name=strReportMonth size=1
  ? // Get This Month
   $strThisMonth = date('m');
   $strThisYear = date('Y');
   // convert to integer
   $strThisMonth++;
   $strNextMonth = $strThisMonth;
   $strPrevYear = $strThisYear;
   for($i=0;$i=12;$i++) {
$strThisMonth--;
if($strNextMonth == 0) {
 $strNextMonth = 12;
}
if($strNextMonth == 13) {
 $strNextMonth = 1;
}
// How many days in this month
$lastday = mktime (0,0,0,$strNextMonth,0,$strThisYear);
$last = strftime (%d, $lastday);
$strThisMonthTS = mktime (0,0,0,$strNextMonth,0,$strThisYear);
$strThisMonthName = strftime (%B, $strThisMonthTS);
$strNextMonth--;
if($strThisMonth == 0) {
 $strThisMonth = 12;
 $strThisYear--;
}
$strPrevMonth = $strThisMonth -1;
if($strPrevMonth == 0) {
 $strPrevMonth = 12;
 $strPrevYear--;
}
$strPrevMonthTS = mktime (0,0,0,$strThisMonth,0,$strPrevYear);
$strPrevMonthName = strftime (%B, $strPrevMonthTS);
if($strPrevMonth  10) {
 $strPrevMonth = 0.$strPrevMonth;
}
if($strThisMonth  10) {
 $strThisMonth = 0.$strThisMonth;
}
?
option value=? print
$strPrevMonth./01/.$strPrevYear.|.$strThisMonth./.$last./.$strThisYear.|.$strThisMonthName.|.$strThisYear.|.$strPrevMonth.|.$strThisMonth.|.$strPrevMonthName.|.$strPrevYear;
?? print $strThisMonthName. .$strThisYear; ?
?
   }
  ?
  /select


Jon Rosenberg wrote:

 I need to make a select list for a web page in the following format:

 01/01/01-01/07/01
 01/08/01-01/14/01
 01/15/01-01/21/01
 etc
 etc
 till the end of 2002 and further in the future eventually

 I'd like to make PHP generate this for me so I don't have to handcode it for
 each year in the future.  I've looked at the date/time functions and I'm a
 bit confused.  Any help would be appreciated.  Thanks!

 Jon

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW  2217
Australia

Phone: +61 2 9553 1691
Fax: +61 2 9553 1692
Mobile: 0419 414 323
eMail: [EMAIL PROTECTED]
http://www.quillsoft.com.au

You can download our Public CA Certificate from:-
https://ca.secureanywhere.com/htdocs/cacert.crt

**

This information contains confidential information intended only for
the use of the authorised recipient.  If you are not an authorised
recipient of this e-mail, please contact Quillsoft Pty Ltd by return
e-mail.
In this case, you should not read, print, re-transmit, store or act
in reliance on this e-mail or any attachments, and should destroy all
copies of them.
This e-mail and any attachments may also contain copyright material
belonging to Quillsoft Pty Ltd.
The views expressed in this e-mail or attachments are the views of
the author and not the views of Quillsoft Pty Ltd.
You should only deal with the material contained in this e-mail if
you are authorised to do so.

This notice should not be removed.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date list

2001-05-01 Thread Tomasz Abramowicz

ahem
$daysinmonth = date('t');

- Original Message -
From: Chris Fry [EMAIL PROTECTED]
To: Jon Rosenberg [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Sent: Wednesday, May 02, 2001 3:06 AM
Subject: Re: [PHP] date list


 Jon,

 Just had to do almost exactly this - here's one solution. The tricky bit
was
 getting the number of days in the month - you have to look at next month!

 This generates a list for 12 months starting with the current month and
outputs
 display stuff as well. In our scenario this is passed to a script which
grabs
 records from a database and produces a report for the month selected and
the
 previous month so the range of values is always for 2 months. Ours goes
 backwards - you'll need to adjust it to run forwards.

   select name=strReportMonth size=1
   ? // Get This Month
$strThisMonth = date('m');
$strThisYear = date('Y');
// convert to integer
$strThisMonth++;
$strNextMonth = $strThisMonth;
$strPrevYear = $strThisYear;
for($i=0;$i=12;$i++) {
 $strThisMonth--;
 if($strNextMonth == 0) {
  $strNextMonth = 12;
 }
 if($strNextMonth == 13) {
  $strNextMonth = 1;
 }
 // How many days in this month
 $lastday = mktime (0,0,0,$strNextMonth,0,$strThisYear);
 $last = strftime (%d, $lastday);
 $strThisMonthTS = mktime (0,0,0,$strNextMonth,0,$strThisYear);
 $strThisMonthName = strftime (%B, $strThisMonthTS);
 $strNextMonth--;
 if($strThisMonth == 0) {
  $strThisMonth = 12;
  $strThisYear--;
 }
 $strPrevMonth = $strThisMonth -1;
 if($strPrevMonth == 0) {
  $strPrevMonth = 12;
  $strPrevYear--;
 }
 $strPrevMonthTS = mktime (0,0,0,$strThisMonth,0,$strPrevYear);
 $strPrevMonthName = strftime (%B, $strPrevMonthTS);
 if($strPrevMonth  10) {
  $strPrevMonth = 0.$strPrevMonth;
 }
 if($strThisMonth  10) {
  $strThisMonth = 0.$strThisMonth;
 }
 ?
 option value=? print

$strPrevMonth./01/.$strPrevYear.|.$strThisMonth./.$last./.$strThisYe
ar.|.$strThisMonthName.|.$strThisYear.|.$strPrevMonth.|.$strThisMont
h.|.$strPrevMonthName.|.$strPrevYear;
 ?? print $strThisMonthName. .$strThisYear; ?
 ?
}
   ?
   /select


 Jon Rosenberg wrote:

  I need to make a select list for a web page in the following format:
 
  01/01/01-01/07/01
  01/08/01-01/14/01
  01/15/01-01/21/01
  etc
  etc
  till the end of 2002 and further in the future eventually
 
  I'd like to make PHP generate this for me so I don't have to handcode it
for
  each year in the future.  I've looked at the date/time functions and I'm
a
  bit confused.  Any help would be appreciated.  Thanks!
 
  Jon
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

 --
 Chris Fry
 Quillsoft Pty Ltd
 Specialists in Secure Internet Services and E-Commerce Solutions
 10 Gray Street
 Kogarah
 NSW  2217
 Australia

 Phone: +61 2 9553 1691
 Fax: +61 2 9553 1692
 Mobile: 0419 414 323
 eMail: [EMAIL PROTECTED]
 http://www.quillsoft.com.au

 You can download our Public CA Certificate from:-
 https://ca.secureanywhere.com/htdocs/cacert.crt

 **

 This information contains confidential information intended only for
 the use of the authorised recipient.  If you are not an authorised
 recipient of this e-mail, please contact Quillsoft Pty Ltd by return
 e-mail.
 In this case, you should not read, print, re-transmit, store or act
 in reliance on this e-mail or any attachments, and should destroy all
 copies of them.
 This e-mail and any attachments may also contain copyright material
 belonging to Quillsoft Pty Ltd.
 The views expressed in this e-mail or attachments are the views of
 the author and not the views of Quillsoft Pty Ltd.
 You should only deal with the material contained in this e-mail if
 you are authorised to do so.

 This notice should not be removed.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date list

2001-05-01 Thread Chris Fry

OOOps!

I got my stuff from the annotated manual - that'll teach me.

Chris

Tomasz Abramowicz wrote:

 ahem
 $daysinmonth = date('t');

 - Original Message -
 From: Chris Fry [EMAIL PROTECTED]
 To: Jon Rosenberg [EMAIL PROTECTED]
 Cc: PHP List [EMAIL PROTECTED]
 Sent: Wednesday, May 02, 2001 3:06 AM
 Subject: Re: [PHP] date list

  Jon,
 
  Just had to do almost exactly this - here's one solution. The tricky bit
 was
  getting the number of days in the month - you have to look at next month!
 
  This generates a list for 12 months starting with the current month and
 outputs
  display stuff as well. In our scenario this is passed to a script which
 grabs
  records from a database and produces a report for the month selected and
 the
  previous month so the range of values is always for 2 months. Ours goes
  backwards - you'll need to adjust it to run forwards.
 
select name=strReportMonth size=1
? // Get This Month
 $strThisMonth = date('m');
 $strThisYear = date('Y');
 // convert to integer
 $strThisMonth++;
 $strNextMonth = $strThisMonth;
 $strPrevYear = $strThisYear;
 for($i=0;$i=12;$i++) {
  $strThisMonth--;
  if($strNextMonth == 0) {
   $strNextMonth = 12;
  }
  if($strNextMonth == 13) {
   $strNextMonth = 1;
  }
  // How many days in this month
  $lastday = mktime (0,0,0,$strNextMonth,0,$strThisYear);
  $last = strftime (%d, $lastday);
  $strThisMonthTS = mktime (0,0,0,$strNextMonth,0,$strThisYear);
  $strThisMonthName = strftime (%B, $strThisMonthTS);
  $strNextMonth--;
  if($strThisMonth == 0) {
   $strThisMonth = 12;
   $strThisYear--;
  }
  $strPrevMonth = $strThisMonth -1;
  if($strPrevMonth == 0) {
   $strPrevMonth = 12;
   $strPrevYear--;
  }
  $strPrevMonthTS = mktime (0,0,0,$strThisMonth,0,$strPrevYear);
  $strPrevMonthName = strftime (%B, $strPrevMonthTS);
  if($strPrevMonth  10) {
   $strPrevMonth = 0.$strPrevMonth;
  }
  if($strThisMonth  10) {
   $strThisMonth = 0.$strThisMonth;
  }
  ?
  option value=? print
 
 $strPrevMonth./01/.$strPrevYear.|.$strThisMonth./.$last./.$strThisYe
 ar.|.$strThisMonthName.|.$strThisYear.|.$strPrevMonth.|.$strThisMont
 h.|.$strPrevMonthName.|.$strPrevYear;
  ?? print $strThisMonthName. .$strThisYear; ?
  ?
 }
?
/select
 
 
  Jon Rosenberg wrote:
 
   I need to make a select list for a web page in the following format:
  
   01/01/01-01/07/01
   01/08/01-01/14/01
   01/15/01-01/21/01
   etc
   etc
   till the end of 2002 and further in the future eventually
  
   I'd like to make PHP generate this for me so I don't have to handcode it
 for
   each year in the future.  I've looked at the date/time functions and I'm
 a
   bit confused.  Any help would be appreciated.  Thanks!
  
   Jon
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
  --
  Chris Fry
  Quillsoft Pty Ltd
  Specialists in Secure Internet Services and E-Commerce Solutions
  10 Gray Street
  Kogarah
  NSW  2217
  Australia
 
  Phone: +61 2 9553 1691
  Fax: +61 2 9553 1692
  Mobile: 0419 414 323
  eMail: [EMAIL PROTECTED]
  http://www.quillsoft.com.au
 
  You can download our Public CA Certificate from:-
  https://ca.secureanywhere.com/htdocs/cacert.crt
 
  **
 
  This information contains confidential information intended only for
  the use of the authorised recipient.  If you are not an authorised
  recipient of this e-mail, please contact Quillsoft Pty Ltd by return
  e-mail.
  In this case, you should not read, print, re-transmit, store or act
  in reliance on this e-mail or any attachments, and should destroy all
  copies of them.
  This e-mail and any attachments may also contain copyright material
  belonging to Quillsoft Pty Ltd.
  The views expressed in this e-mail or attachments are the views of
  the author and not the views of Quillsoft Pty Ltd.
  You should only deal with the material contained in this e-mail if
  you are authorised to do so.
 
  This notice should not be removed.
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW  2217
Australia

Phone: +61 2 9553 1691
Fax: +61 2 9553 1692
Mobile: 0419 414 323
eMail: [EMAIL PROTECTED]
http