Date format convert javascript

后端 未结 5 1091
再見小時候
再見小時候 2021-01-19 01:01

I am trying to convert \"July 24 2013\" to \"DD-MM-YYYY\" with javascript but I keep getting and error.

I am using new Date(\'July 24 2013\').format(\"DD-MM-YY

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 01:34

    Date object doesn't have .format() method. If you work with date and time actively I'd recommend you to use MomentJS library then. It has a lot of useful functionality to work with time and date.

    For example: moment('July 24 2013', 'MMMM D YYYY').format('MMMM D YYYY, h:mm:ss a');

提交回复
热议问题