note 69534 deleted from function.time by aidan

From: Date: Wed, 15 Apr 2009 16:00:47 +0000
Subject: note 69534 deleted from function.time by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153320@lists.php.net to get a copy of this message
Note Submitter: krisdover at hotmail dot com ---- # a simple html/php formatted calendar which returns # the date as a unix timestamp when the required day # is selected. Also allows for setting of time in 24hr format # kris dover, 2006-09-09 <?php $sel_date = isset($_REQUEST['sel_date']) ? $_REQUEST['sel_date'] : time(); if( isset($_POST['hrs']) ){ $t = getdate($sel_date); $sel_date = mktime($_POST['hrs'], $_POST['mins'], $t['seconds'], $t['mon'], $t['mday'], $t['year']); } $t = getdate($sel_date); $start_date = mktime($t['hours'], $t['minutes'], $t['seconds'], $t['mon'], 1, $t['year']); $start_date -= 86400 * date('w', $start_date); $prev_year = mktime($t['hours'], $t['minutes'], $t['seconds'], $t['mon'], $t['mday'], $t['year'] - 1); $prev_month = mktime($t['hours'], $t['minutes'], $t['seconds'], $t['mon'] - 1, $t['mday'], $t['year']); $next_year = mktime($t['hours'], $t['minutes'], $t['seconds'], $t['mon'], $t['mday'], $t['year'] + 1); $next_month = mktime($t['hours'], $t['minutes'], $t['seconds'], $t['mon'] + 1, $t['mday'], $t['year']); ?> <form method="post"> <table width="180" border="0" cellspacing="1" style="border: 1px solid black; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; text-align: center"> <tr> <td width="14%" bgcolor="#66FF99"> <a href="?sel_date=<?= $prev_year ?>" style="text-decoration: none" title="Prevous Year">&lt;&lt;</a></td> <td width="14%" bgcolor="#66FF99"> <a href="?sel_date=<?= $prev_month ?>" style="text-decoration: none" title="Prevous Month">&lt;</a></td> <td colspan="3" bgcolor="#66FF99"> <?= date('M Y', $sel_date) ?> </td> <td width="14%" bgcolor="#66FF99"> <a href="?sel_date=<?= $next_month ?>" style="text-decoration: none" title="Next Month">&gt;</a></td> <td width="14%" bgcolor="#66FF99"> <a href="?sel_date=<?= $next_year ?>" style="text-decoration: none" title="Next Year">&gt;&gt;</a></td> </tr> <tr> <td bgcolor="#0099FF">Sun</td> <td bgcolor="#0099FF">Mon</td> <td width="14%" bgcolor="#0099FF">Tue</td> <td width="14%" bgcolor="#0099FF">Wed</td> <td width="14%" bgcolor="#0099FF">Thu</td> <td bgcolor="#0099FF">Fri</td> <td bgcolor="#0099FF">Sat</td> </tr> <?php $day = 1; for($i = $start_date; $day <= 42; $i+=86400, $day++){ if( $day % 7 == 1 ) echo "<tr>\n"; if( $t['mon'] == date('n', $i ) ) if( $i == $sel_date ) echo ' <td bgcolor="gold">'. date('j', $i) ."</td>\n"; else echo ' <td><a href="?sel_date='. $i .'" style="text-decoration: none">'. date('j', $i) ."</a></td>\n"; else echo ' <td ><a href="?sel_date='. $i .'" style="text-decoration: none"><font color="silver">'. date('j', $i) ."</font></a></td>\n"; if( $day % 7 == 0 ) echo "</tr>\n"; } ?> <tr> <td colspan="7" align="left" bgcolor="silver">Time: <select name="hrs" onchange="document.forms[0].submit()"> <?php for($i = 0; $i < 24; $i++) echo ' <option '. (date('G', $sel_date)==$i ? 'selected':'') .'>'. sprintf('%02d', $i) ."</option>\n"; ?> </select>: <select name="mins" onchange="document.forms[0].submit()"> <?php for($i = 0; $i < 60; $i++) echo ' <option '. (date('i', $sel_date)==$i ? 'selected':'') .'>'. sprintf('%02d', $i) ."</option>\n"; ?> </select> hrs <input type="hidden" name="sel_date" value="<?= $sel_date ?>"> </td> </tr> </table> </form>

« previous php.notes (#153320) next »