Use moment().isSame() to check if a moment is the same as another moment. The first argument will be parsed as a moment, if not already so.
Passing in month will check month and year. Passing in day will check day, month, and year
Docs: https://momentjscom.readthedocs.io/en/latest/moment/05-query/02-is-same/
var input = "2020-03-29 17:03:04"; console.log(moment(input).isSame("2020-12-31", "year"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.