Currently, I am working with an array of timestamps and respective values. For each timestamp, I am converting it into a date format. There is a function in place that displays the dates from oldest to newest. My goal is to calculate time frames such as last week
, last month
, and last year
based on today's date.
const myData = [
{timestamp: 1382086394000, value: 200},
{timestamp: 1382086394001, value: 200},
{timestamp: 1232131231232, value: 300},
{timestamp: 2131231241212, value: 400},
{timestamp: 1234124124112, value: 285},
{timestamp: 1251251251251, value: 123},
{timestamp: 1241241241241, value: 512},
{timestamp: 1241241241241, value: 124},
{timestamp: 2312312123121, value: 600},
];
This represents how the current array appears after converting the timestamps to actual dates. It's important to note that this conversion has already been done.