-1

I want to release particles every hour for a month and need an array with a date in this format '2013/05/23;00:00:00:000' (YYYY/MM/DD;hh:mm:SS:sss) that has the following hour in every step. So something like this for a whole month:

x=['2013/05/23;01:00:00:000' '2013/05/23;02:00:00:000' '2013/05/23;03:00:00:000' ...'2013/06/23;01:00:00:000']

Any idea how to loop this? Thanks!

Jellyse
  • 839
  • 7
  • 22

2 Answers2

0

Something along the lines

import datetime as dt

dt_start = dt.datetime(2013,5,23,1,0)
dt_end = dt.datetime(2013,5,23,4,0)

date_list = []
while dt_start< dt_end:
  dt_start = dt_start + dt.timedelta(hours=1)
  date_list.append('{:%Y/%m/%d;%H:%M:%S:%f}'.format(dt_start))
mzoll
  • 475
  • 3
  • 11
-1
i = 1
x = []    
while i<=12:
    if i<10:
        str = '2013/05/23;0%d:00:00:000' % i
    else:
        str = '2013/05/23;%d:00:00:000' % i
    x.append(str)
    i=i+1

this is code

유재영
  • 251
  • 1
  • 4
  • 11