note 101531 added to function.idate

From: Date: Wed, 22 Dec 2010 22:07:33 +0000
Subject: note 101531 added to function.idate
Groups: php.notes 
Request: Send a blank email to php-notes+get-175147@lists.php.net to get a copy of this message
A function that made by idate for print a hour you want: <?php function hour ( $a, $b ) { $timestamp = strtotime(''.$a.':'.$b.':00'); $aa = idate('H', $timestamp); $bb = idate('i', $timestamp); if($bb=="0") { $cc = "00"; } else { $cc = $bb; } $dd = $aa.".".$cc; return($dd); } ?> Why should i use it? For example: You have to print 08:00 to 21:00 by 15 minutes periods. This is a useful code for shipping sites for delivery time. <?php echo "<select name=\"example\">"; for($i=8;$i<=20;$i++) { for($ii=0;$ii<=3;$ii++) { $iii = $ii * 15; $hour = hour($i, $iii); echo "<option value=\"".$hour."\">".$hour."</option>"; } } echo "</select>"; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 81.213.140.147 ---- Manual Page -- http://www.php.net/manual/en/function.idate.php Edit -- https://master.php.net/note/edit/101531 Del: integrated -- https://master.php.net/note/delete/101531/integrated Del: useless -- https://master.php.net/note/delete/101531/useless Del: bad code -- https://master.php.net/note/delete/101531/bad+code Del: spam -- https://master.php.net/note/delete/101531/spam Del: non-english -- https://master.php.net/note/delete/101531/non-english Del: in docs -- https://master.php.net/note/delete/101531/in+docs Del: other reasons-- https://master.php.net/note/delete/101531 Reject -- https://master.php.net/note/reject/101531 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175147) next »