note 55229 deleted from function.strtotime by derick

From: Date: Sun, 15 Jul 2007 12:47:28 +0000
Subject: note 55229 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128578@lists.php.net to get a copy of this message
Note Submitter: sales at chumpstump dot com ---- I needed a drop down box so users could see their account balance for the given time period. Below is a drop box that displays the first of the month for the last twelve months and the value of each is the timestamp of that date. <? $time = time(); $month = date("F"); $year = date("Y"); $string = "1 "; $string .= $month; $string .= " "; $string .= $year; $first_timestamp = strtotime($string); $start_box = "<select name='start_date' size='1'><option>Start Date</option>"; $end_box = "<select name='end_date' size='1'><option>End Date</option>"; for ($i = 0; $i <= 12; $i++) { $temp = "-"; $temp .= $i; $temp .= " month"; $timestamp_first = strtotime($temp, $first_timestamp); $formatted_first = date("F j, Y", $timestamp_first); $box .= "\n<option value='"; $box .= $timestamp_first; $box .= "'>"; $box .= $formatted_first; $box .= "</option>\n"; } $start_box .= $box; $end_box .= $box; $start_box .= "</select>"; $end_box .= "</select>"; ?> Once submitted it was very easy to pull from the db what you needed between the two timestamps. I'm sure it could be condensed a bit, but the logic is there. Hope this helps someone. GG

« previous php.notes (#128578) next »