Having some trouble with formatting dates for MySQL insertion. Here is the current HTML structure:
<strong id="ut-open-date">27/06/2014</strong>
I need to convert the date format to "YYYY-MM-DD" using moment.js library. My code snippet is as follows:
var CreateDate = moment(jQuery('#ut-open-date').html()).format("DD/MM/YYYY");
CreateDate = moment(CreateDate).format("YYYY-MM-DD");
The issue I am facing is that the output changes from 27/06/2014
to 2016-06-03
, and I'm not sure why.
I have also tried the following code with the same incorrect result:
var CreateDate = moment(jQuery('#ut-open-date').html()).format("YYYY-MM-DD");
If anyone could provide assistance, it would be greatly appreciated.