Generating 15 minute time interval array in python
<p>I am new to python. I am trying to generate time interval array. for example:
<code>
time_array = 
["2016-09-02T17:30:00Z", "2016-09-02T17:45:00Z", "2016-09-02T18:00:00Z", "2016-09-02T18:15:00Z", "2016-09-02T18:30:00Z", "2016-09-02T18:45:00Z"]
</code>
1. It should create the element like above in zulu time till 9 pm everyday.
2. Should generate the elements for next and day after next as well
3. Start time from 7:00 am - Ed time 9:00 pm,
if current_time is > start_time then generate 15 min time interval array till 9 pm. and then generate for next day and day + 2.
And Interval should be 7:00, 7:15 like that.. not in 7:12, 8:32</p>

<p>Here's a generic <code>datetime_range</code> for you to use.</p>

<h3>Code</h3>

<pre><code>from datetime import datetime, timedelta

def datetime_range(start, end, delta):
    current = start
    while current &lt; end:
        yield current
        current += delta

dts = [dt.strftime('%Y-%m-%d T%H:%M Z') for dt in 
       datetime_range(datetime(2016, 9, 1, 7), datetime(2016, 9, 1, 9+12), 
       timedelta(minutes=15))]

print(dts)
</code></pre>

<h3>Output</h3>

<blockquote>
  <p>['2016-09-01 T07:00 Z', '2016-09-01 T07:15 Z', '2016-09-01 T07:30 Z', '2016-09-01 T07:45 Z', '2016-09-01 T08:00 Z', '2016-09-01 T08:15 Z', '2016-09-01 T08:30 Z', '2016-09-01 T08:45 Z', '2016-09-01 T09:00 Z', '2016-09-01 T09:15 Z', '2016-09-01 T09:30 Z', '2016-09-01 T09:45 Z' ... ]</p>
</blockquote>

python arrays python-2.7