Every document in Mongo
has timestamp in millisecond
s and I get array of documents as result of query. How to cluster data to array of arrays
where inner array are documents which belongs to same month
? ( Have to to do this also for weeks
, week starts at Monday
and the last day is Sunday
).
You can get the month and weekday with the time package:
package main
import "fmt"
import "time"
func main() {
ms := int64(0)
t := time.Unix(0, ms*int64(time.Millisecond))
fmt.Println(t.Month(), t.Weekday())
}