function formatDate(date, chars = '') {
	return chars.split('').reduce((str, char) => {
		switch(char) {
			case 'Y':
				str += date.getFullYear();
				break;
			case 'y':
				str += date.getYear();
				break;
			case 'M':
				str += MONTHS[date.getMonth()].abbr;
				break;
			case 'F':
				str += MONTHS[date.getMonth()].full;
				break;
			case 'm':
				var m = date.getMonth() + 1;
				str += m < 10 ? `0${m}` : m;
				break;
			case 'n':
				str += date.getMonth() + 1;
				break;
			case 'd':
				var d = date.getDate();
				str += d < 10 ? `0${d}` : d;
				break;
			case 'N':
				str += date.getDay() + 1;
				break;
			case 'j':
				str += date.getDate();
				break;
			case 'D':
				str += DAYS[date.getDay() - 1].abbr;
				break;
			case 'l':
				str += DAYS[date.getDay() - 1].full;
				break;
			case 'H':
				var h = date.getHours();
				str += h < 10 ? `0${h}` : h;
				break;
			case 'h':
				var H = (date.getHours() % 12) + 1;
				str += H < 10 ? `0${H}` : H;
				break;
			case 'G':
				str += date.getHours();
				break;
			case 'g':
				str += (date.getHours() % 12) + 1;
				break;
			case 'i':
				var i = date.getMinutes();
				str += i < 10 ? `0${i}` : i;
				break;
			case 's':
				var s = date.getSeconds();
				str += s < 10 ? `0${s}` : s;
				break;
			case 'a':
				str += date.getHours() > 11 ? 'pm' : 'am';
				break;
			case 'A':
				str += date.getHours() > 11 ? 'PM' : 'AM';
				break;
			default:
				str += char;
		}
		return str;
	}, '');
}
/**
 * Similar to PHP Date::format <https://secure.php.net/manual/en/function.date.php>
 * @TODO Add support for more formatting options, including /especially timezones
 */
Similar to PHP Date::format
@TODO Add support for more formatting options, including /especially timezones
Similar to PHP Date :: format @TODO Add support for more formatting options including / especially timezones
function formatDate(date, chars = '') {
	return chars.split('').reduce((str, char) => {
		switch(char) {
			case 'Y':
				str += date.getFullYear();
				break;
			case 'y':
				str += date.getYear();
				break;
			case 'M':
				str += MONTHS[date.getMonth()].abbr;
				break;
			case 'F':
				str += MONTHS[date.getMonth()].full;
				break;
			case 'm':
				var m = date.getMonth() + 1;
				str += m < 10 ? `0${m}` : m;
				break;
			case 'n':
				str += date.getMonth() + 1;
				break;
			case 'd':
				var d = date.getDate();
				str += d < 10 ? `0${d}` : d;
				break;
			case 'N':
				str += date.getDay() + 1;
				break;
			case 'j':
				str += date.getDate();
				break;
			case 'D':
				str += DAYS[date.getDay() - 1].abbr;
				break;
			case 'l':
				str += DAYS[date.getDay() - 1].full;
				break;
			case 'H':
				var h = date.getHours();
				str += h < 10 ? `0${h}` : h;
				break;
			case 'h':
				var H = (date.getHours() % 12) + 1;
				str += H < 10 ? `0${H}` : H;
				break;
			case 'G':
				str += date.getHours();
				break;
			case 'g':
				str += (date.getHours() % 12) + 1;
				break;
			case 'i':
				var i = date.getMinutes();
				str += i < 10 ? `0${i}` : i;
				break;
			case 's':
				var s = date.getSeconds();
				str += s < 10 ? `0${s}` : s;
				break;
			case 'a':
				str += date.getHours() > 11 ? 'pm' : 'am';
				break;
			case 'A':
				str += date.getHours() > 11 ? 'PM' : 'AM';
				break;
			default:
				str += char;
		}
		return str;
	}, '');
}
function formatDate ( date , chars = '' ) { return chars . split ( '' ) . reduce ( ( str , char ) => { switch ( char ) { case 'Y' : str += date . getFullYear ( ) ; break ; case 'y' : str += date . getYear ( ) ; break ; case 'M' : str += MONTHS [ date . getMonth ( ) ] . abbr ; break ; case 'F' : str += MONTHS [ date . getMonth ( ) ] . full ; break ; case 'm' : var m = date . getMonth ( ) + 1 ; str += m < 10 ? ` ${ m } ` : m ; break ; case 'n' : str += date . getMonth ( ) + 1 ; break ; case 'd' : var d = date . getDate ( ) ; str += d < 10 ? ` ${ d } ` : d ; break ; case 'N' : str += date . getDay ( ) + 1 ; break ; case 'j' : str += date . getDate ( ) ; break ; case 'D' : str += DAYS [ date . getDay ( ) - 1 ] . abbr ; break ; case 'l' : str += DAYS [ date . getDay ( ) - 1 ] . full ; break ; case 'H' : var h = date . getHours ( ) ; str += h < 10 ? ` ${ h } ` : h ; break ; case 'h' : var H = ( date . getHours ( ) % 12 ) + 1 ; str += H < 10 ? ` ${ H } ` : H ; break ; case 'G' : str += date . getHours ( ) ; break ; case 'g' : str += ( date . getHours ( ) % 12 ) + 1 ; break ; case 'i' : var i = date . getMinutes ( ) ; str += i < 10 ? ` ${ i } ` : i ; break ; case 's' : var s = date . getSeconds ( ) ; str += s < 10 ? ` ${ s } ` : s ; break ; case 'a' : str += date . getHours ( ) > 11 ? 'pm' : 'am' ; break ; case 'A' : str += date . getHours ( ) > 11 ? 'PM' : 'AM' ; break ; default : str += char ; } return str ; } , '' ) ; }
Similar to PHP Date::format <https://secure.php.net/manual/en/function.date.php>
 @TODO Add support for more formatting options, including /especially timezones
Similar to PHP Date :: format <https : // secure . php . net / manual / en / function . date . php > @TODO Add support for more formatting options including / especially timezones