Custom-Meta-Boxes icon indicating copy to clipboard operation
Custom-Meta-Boxes copied to clipboard

Unix date being saved as formated date

Open grappler opened this issue 8 years ago • 3 comments

I am running WP 4.6 with the version of CMB from 5th October, commit https://github.com/humanmade/Custom-Meta-Boxes/commit/6f78ad4e0292b99c786a24b51c4afc09aab9bde7

The date gets converted to strtotime but then last minute before the setting is saved it is changed back to a formated state.

grappler avatar Nov 04 '16 06:11 grappler

Date-related issues: #175, #292, #249, #133, #146

swissspidy avatar Nov 07 '16 09:11 swissspidy

@grappler are you still experiencing this? Any thoughts or ideas on the bug?

mikeselander avatar Dec 14 '17 00:12 mikeselander

@mikeselander This is the code that we are using to fix this.

class DateTimestampField extends CMB_Date_Timestamp_Field {

	/**
	 * Parse and validate an array of timestamp values.
	 */
	public function parse_save_values() : void {
		// Prevent saving this field twice.
		unset( $_POST[ '_cmb_present_' . $this->id ] );

		foreach ( $this->values as &$value ) {
			$value = strtotime( $value );
		}

		sort( $this->values );
	}
}

grappler avatar Dec 14 '17 09:12 grappler