@dedrick
To get the right format in Moment.js, you can use the format()
function. Here's an example:
1 2 3 4 5 6 |
const moment = require('moment'); const currentDate = moment(); const formattedDate = currentDate.format('YYYY-MM-DD HH:mm:ss'); console.log(formattedDate); |
In this example, currentDate.format('YYYY-MM-DD HH:mm:ss')
will return the formatted date in the desired format, which is YYYY-MM-DD HH:mm:ss
. You can change the format according to your needs.
Note that you would need to have Moment.js library installed and included in your code before you can use it.