jQuery Plugin: MySQL DateTime to Input Date Format
Simple solutions to convert MySQL DateTime to Input Date Format. You may change the format as your requirement.
$.extend({ getInputDateFromMySQLDate: function(value) { var t = value.split(/[- :]/); var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]); var day = ("0" + d.getDate()).slice(-2); var month = ("0" + (d.getMonth() + 1)).slice(-2); return d.getFullYear()+"-"+(month)+"-"+(day); }, getDateFromMySQLDate: function(value){ var t = value.split(/[- :]/); return new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]); } });
References:
- http://stackoverflow.com/questions/3075577/convert-mysql-datetime-stamp-into-javascripts-date-format
- http://stackoverflow.com/questions/12346381/set-date-in-input-type-date