Created
          November 5, 2015 11:46 
        
      - 
      
- 
        Save taher435/972f3f9db117148e8b53 to your computer and use it in GitHub Desktop. 
    Create time drop down with customisable interval
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def time_iterate(start_time, end_time, step, &block) | |
| begin | |
| yield(start_time) | |
| end while (start_time += step) <= end_time | |
| end | |
| start_time = Time.parse("2010/1/1") | |
| end_time = Time.parse("2010/1/2") | |
| time_iterate(start_time, end_time, 1800) do |t| | |
| hours.push({:text => t.strftime("%H:%M"), :hour => t.hour}) | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
time drop down with intervals in ruby