Tech Hacks

JavaScript Date Format YYYY-MM-DD

Here is a simple function that takes the input of JS Date and returns a string of format YYYY-MM-DD:

var getDateFromDateTime = function(date) {
date = new Date(date); //Using this we can convert any date format to JS Date
var mm = date.getMonth() + 1; // getMonth() is zero-based
var dd = date.getDate();
if(mm