How to convert moment date to a string and remove the moment object

后端 未结 2 1761
北海茫月
北海茫月 2021-02-07 05:19

I have a React Web App and a React Native Mobile App. When I pass a moment date object from my react web app to my backend, it gets converted to a string somehow and it works wi

2条回答
  •  半阙折子戏
    2021-02-07 05:51

    Use moment().format() to create a formatted string from the date.

    console.log(moment().format())

    But if you're using version 2.1.0+ (link), toString should work:

    console.log(moment().toString())
    console.log(typeof moment().toString())

提交回复
热议问题