How to convert dates to UNIX timestamps in MomentJS?
问题 I want to convert my date time values to Unix timestamp format (basically an epoch timestamp). For that I use: let startDate = '2018-09-28 11:20:55'; let endDate = '2018-10-28 11:20:55'; let test1 = startDate.unix(); let test2 = endDate.unix(); However it gives me an error ERROR TypeError: Cannot read property 'Unix' of undefined Can anyone tell me how I can convert datetime to Unix using MomentJS? 回答1: The issue is because you're calling unix() on plain strings. You need to instead call it