Date.prototype.format = function(templateString:string):string{
	//https://www.php.net/manual/en/datetime.format.php
	//missing: z, W, t, L,o,X,x,a,A,B,g,G,h,u,v,e,I,O,P,p,T,Z,c,r,U
	let replaceLib:{[key:string]:string} = {};
	replaceLib.d = (this.getUTCDate()+'').padStart(2,'0');

	replaceLib.H = (this.getUTCHours()+'').padStart(2,'0');
	replaceLib.i = (this.getUTCMinutes()+'').padStart(2,'0');
	replaceLib.s = (this.getUTCSeconds()+'').padStart(2,'0');

	switch(this.getUTCDay()){
		case 0: 
			replaceLib.D = 'Sun';
			replaceLib.l = 'Sunday';
			break;
		case 1:
			replaceLib.D = 'Mon';
			replaceLib.l = 'Monday';
			break;
		case 2:
			replaceLib.D = 'Tue';
			replaceLib.l = 'Tuesday';
			break;
		case 3:
			replaceLib.D = 'Wed';
			replaceLib.l = 'Wednesday';
			break;
		case 4:
			replaceLib.D = 'Thu';
			replaceLib.l = 'Thursday';
			break;
		case 5:
			replaceLib.D = 'Fri';
			replaceLib.l = 'Friday';
			break;
		case 6:
			replaceLib.D = 'Sat';
			replaceLib.l = 'Saturday';
			break;
	}

	replaceLib.j = this.getUTCDate()+'';
	replaceLib.N = this.getUTCDay()+'' || '7';
	replaceLib.w = this.getUTCDay()+'';

	switch(this.getUTCDate()){
		case 1:		replaceLib.S = 'st';	break;
		case 2:		replaceLib.S = 'nd';	break;
		case 3:		replaceLib.S = 'rd';	break;
		default:	replaceLib.S = 'th';	break;
	}

	switch(this.getUTCMonth()){
		case 0:
			replaceLib.F = 'January';
			replaceLib.M = 'Jan';
			replaceLib.m = '1';
			replaceLib.n = '1';
		case 1:
			replaceLib.F = 'February';
			replaceLib.M = 'Feb';
			replaceLib.m = '2';
			replaceLib.n = '02';
			break;
		case 2:
			replaceLib.F = 'March';
			replaceLib.M = 'Mar';
			replaceLib.m = '3';
			replaceLib.n = '03';
			break;
		case 3:
			replaceLib.F = 'April';
			replaceLib.M = 'Apr';
			replaceLib.m = '4';
			replaceLib.n = '04';
			break;
		case 4:
			replaceLib.F = 'May';
			replaceLib.M = 'May';
			replaceLib.m = '5';
			replaceLib.n = '05';
			break;
		case 5:
			replaceLib.F = 'June';
			replaceLib.M = 'Jun';
			replaceLib.m = '6';
			replaceLib.n = '06';
			break;
		case 6:
			replaceLib.F = 'July';
			replaceLib.M = 'Jul';
			replaceLib.m = '7';
			replaceLib.n = '07';
			break;
		case 7:
			replaceLib.F = 'August';
			replaceLib.M = 'Aug';
			replaceLib.m = '8';
			replaceLib.n = '08';
			break;
		case 8:
			replaceLib.F = 'September';
			replaceLib.M = 'Sep';
			replaceLib.m = '9';
			replaceLib.n = '09';
			break;
		case 9:
			replaceLib.F = 'October';
			replaceLib.M = 'Oct';
			replaceLib.m = '10';
			replaceLib.n = '10';
			break;
		case 10:
			replaceLib.F = 'November';
			replaceLib.M = 'Nov';
			replaceLib.m = '11';
			replaceLib.n = '11';
			break;
		case 11:
			replaceLib.F = 'December';
			replaceLib.M = 'Dec';
			replaceLib.m = '12';
			replaceLib.n = '12';
			break;
	}

	replaceLib.Y = this.getUTCFullYear()+'';
	replaceLib.y = (this.getUTCFullYear() % 100)+'';

	let result = '';

	for(const char of templateString){
		if(replaceLib[char])
			result += replaceLib[char];
		else
			result += char;
	}

	return result;
}