Probably best to use a library like Date.js (although that hasn't been maintained in years) or Moment.js. But to do it manually, you can use Date#getFullYear(), Date#getMonth() (it starts with 0 = January, so you probably want + 1), and Date#getDate() (day of month).
Does anyone know how to convert JS dateTime to MySQL datetime? Also is there a way to add a specific number of minutes to JS datetime and then pass it to MySQL datetime?
Some of the answers given here are either overcomplicated or just will not work (at least, not in all browsers). If you take a step back, you can see that the MySQL timestamp has each component of time in the same order as the arguments required by the Date() constructor.
Given your clarification that you cannot change the format of the incoming date, you need something like this: Var dateParts = isoFormatDateString.split("-"); var jsDate = new Date(dateParts, dateParts - 1, dateParts.substr(0,2)); Original response...
SQL Quiz. MySQL DATE_FORMAT() Function. ❮ MySQL Date Functions. Definition and Usage. The DATE_FORMAT() function is used to display date/time data in different formats. Syntax.
3. DATE_FORMAT() function in MySQL.
Here's a simple version for date formating i use between displaying in HTML and converting back to MYSQL format: <?php function format_date($original='' ...