Return to Snippet

Revision: 63660
at May 27, 2013 09:21 by donkeykong


Initial Code
<?php

$hour_slot 	= 0;
$min_slot 	= 0;

for( $i = 0; $i<47; $i++)
{
	if( $i == 0)
	{
		$str_time 				= date('g:i A', strtotime($hour_slot.':'.$min_slot) );
		$arr_time[$str_time] 	= $str_time;
	}
	
	if( $i%2 == 0 )
	{
		$min_slot=30;
	}
	else
	{
		$min_slot=0;
	}
	
	$str_time 				= date('g:i A', strtotime($hour_slot.':'.$min_slot) );
	$arr_time[$str_time] 	= $str_time;
	
	if( $i%2 == 0 )
	{
		$hour_slot++;
	}
}

?>

Initial URL


Initial Description
These arrays are good for filling out a drop down menu for time that increments by 30 minutes.  The forms can submit the data and be useful for inserting it into a database for time of day information.

Initial Title
Time of Day Incremented every 30 Minutes Array

Initial Tags


Initial Language
PHP