Hi all I am new to date time things in javascript. I am facing one issue while comparing two different date formats. Objective- I want to compare date/time coming from the backend with the current time. If time coming from backend is past time I need to do some other stuff or if it is in future I want to do something else.
Issue- Current date format is something like this - Mon Jan 10 2022 16:38:58 GMT+0530 (India Standard Time) Date Time getting from backend is like - 2022-01-03T18:30:00Z
Code -
$scope.getTimeDifference = function(meetingsData){ meetingsData.forEach(function (arrayItem) { var currentTime = new Date(); var x = arrayItem.meetingTime; console.log(x); console.log(currentTime) if(x < currentTime){ console.log("meeting is in the past"); } else{ console.log("Meeting is in future"); } }); Output - Meeting is in future
Issue - Using this code I am getting meetings in future, but all the meeting time is actually past time. How can I resolve this issue?