Convert the PHP date format string to a JavaScript date format

function date_format_php_to_js( $php_date_format ) {	
	$formats_php_to_js = array(
		'F j, Y' => 'MM dd, yy',
		'Y/m/d'  => 'yy/mm/dd',
		'm/d/Y'  => 'mm/dd/yy',
		'd/m/Y'  => 'dd/mm/yy',
	);
	return isset( $formats_php_to_js[ $php_date_format ] ) ? $formats_php_to_js[ $php_date_format ] : 'MM dd, yy';
}

No comments yet.

Leave a Reply