Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix date being saved as formated date #358

Open
grappler opened this issue Nov 4, 2016 · 3 comments
Open

Unix date being saved as formated date #358

grappler opened this issue Nov 4, 2016 · 3 comments
Labels

Comments

@grappler
Copy link

grappler commented Nov 4, 2016

I am running WP 4.6 with the version of CMB from 5th October, commit 6f78ad4

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

@swissspidy
Copy link
Contributor

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

@mikeselander
Copy link
Contributor

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

@grappler
Copy link
Author

@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 );
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants