LLMS_Metabox_Date_Field::jquery_date_to_php_format( $js_format )


Source Source

File: includes/admin/post-types/meta-boxes/fields/llms.class.meta.box.date.php

	function jquery_date_to_php_format( $js_format ) {
		// Mapping of jQuery UI Datepicker tokens to PHP date format tokens
		$replacements = array(
			// Year tokens
			'yy' => 'Y',  // 4-digit year
			'y'  => 'y',  // 2-digit year

			// Month tokens
			'mm' => 'm',  // Month with leading zero
			'm'  => 'n',  // Month without leading zero
			'MM' => 'F',  // Full month name
			'M'  => 'M',  // Short month name

			// Day tokens
			'dd' => 'd',  // Day with leading zero
			'd'  => 'j',  // Day without leading zero
			'DD' => 'l',  // Full day name
			'D'  => 'D',   // Short day name
		);

		// Sort keys descending by length to avoid partial replacements.
		uksort(
			$replacements,
			function ( $a, $b ) {
				return strlen( $b ) - strlen( $a );
			}
		);

		return strtr( $js_format, $replacements );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.