What timezone are you in? What difference is there between your TZ and the TZ of the CircleCI servers? I would guess the servers are in UTC but you may wish to find out (get an SSH session and use the console). My guess is the TZ difference is 5 hours.
I suspect you have a bug that you need to fix, or your expected results were derived from running this code only in your timezone.
I think you are jumping too far ahead. You need to do some debugging first to see what the correct results are, given that your expected results might be wrong.
Then, show the code you do have, so people can see if there is something wrong with it, rather than asking them to code something from scratch. You may find a Stack Overflow question is more appropriate here anyway - there are more JS eyeballs over there.