Skip to content
Advertisement

Convert JS date time to MySQL datetime

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?

Advertisement

Answer

JavaScript

or even shorter:

JavaScript

Output:

JavaScript

For more advanced use cases, including controlling the timezone, consider using http://momentjs.com/:

JavaScript

For a lightweight alternative to , consider https://github.com/taylorhakes/fecha

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement