Tech Hacks

Convert JavaScript Date format YYYYMMDD

Here is a simple function that takes the input of JS Date and returns a string of format YYYYMMDD:

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