Solved

# Convert a 1D array of timestamps into a 2D array (time-group-mid-point, frequency)

Posted on 2016-08-08

Say I have an array of unix timestamps, and I want to draw a graph showing time across the X axis, and frequency on the Y axis, I need to convert that 1D array into a 2D array (time-group-mid-point, frequency)

[for ease of reading, I've used standard time, but in reality, this will be unix timestamps)

so for example:

11:25:00

12:20:00

12:29:00

12:45:00

13:00:00

13:15:00

and if I want the groups to be 60 minutes, but offset by 30 minutes (halfthe interval, each way)

would become:

10:30 to 11:30 (11:00) = 1

11:30 to 12:30 (12:00) = 2

12:30 to 13:30 (13:00) = 3

13:30 to 14:30 (14:00) = 0

Can anyone suggest a function to do this, or even the correct mathematical terminology so I can research it further.

Thanks.