Background:
I'm working on a fit-bit fitness application. So I get updates from the fit-bit API with date, time and the heart-rate at that point in the following format:
date = "2021-02-01"
time = "14:15:00"
bpm: 78
Now, I need to convert this to a timestamp and save the heart-rate in the format =>(timestamp: heart-rate) I query the heartrate data from the app based on the timetsamp - so they have to match.
Problem: I am parsing the given data using moment.js to get the timestamp,
let date = "2021-02-01"
let time = "14:15:00"
let t = moment(`${date} ${time}`, 'yyyy-mm-dd hh:mm:ss').valueOf();
console.log("Timestamp", t, new Date(t).toUTCString())
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous"></script>
For the above code, I am getting different values:
On my backend server where the database is updated :
"Timestamp", 1609510500000 Fri, 01 Jan 2021 14:15:00 GMT Fri,
As you can see it maps to Jan 1, please help