Custom-Meta-Boxes
Custom-Meta-Boxes copied to clipboard
Unix date being saved as formated date
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.
Date-related issues: #175, #292, #249, #133, #146
@grappler are you still experiencing this? Any thoughts or ideas on the bug?
@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 );
}
}