How to check for two timestamp for the same day?
Input: TimeStamp1 = 20-04-2020 , 16:04:55 and TimeStamp2 = 20-04-2020 , 10:22:42 Output: These dates are of same date
Input: TimeStamp1 = 20-04-2020 , 16:04:55 and TimeStamp2 = 20-04-2019 , 10:22:42 Output: These timestamps are not on the same date.
var D1 = new Date(2020, 04, 20, 16, 04, 55) var D2 = new Date(2020, 04, 20, 10, 22, 42)
Time Stamp Wed May 20 2020 16:04:55 GMT+0530 (India Standard Time) and Wed May 20 2020 10:22:42 GMT+0530 (India Standard Time) is of same day.
Approach 2: You have to set hours, minutes and seconds all equal to 0 by setHours() method and then compare both.
Time Stamp Wed May 20 2020 00:00:00 GMT+0530 (India Standard Time) and Thu May 21 2020 00:00:00 GMT+0530 (India Standard Time) is of different day.