var beginningTime = moment('1635750314812', 'YYYY/MM/DD'); // Today date var endTime = moment(undefined, 'YYYY/MM/DD') // Today date console.log(beginningTime.isSame(endTime)); //expect true <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script> I am using moment js to get if 2 date are the same using the above pattern. But now i get false instead of true. How to solve the issue?
moment('1635750314812', 'YYYY/MM/DD')means parse1635750314812assuming it is inYYYY/MM/DDformat. Which it's clearly not.'YYYY/MM/DD'is supposed to inform Moment about the format of the first argument.moment('1635750314812', 'YYYY/MM/DD')means : "Hey Moment, I'm informing you that'1635750314812'is in format'YYYY/MM/DD'). Moment is like 'Wat?' and produces an invalid Moment object. Log it, it says_isValid:false.