I'm half asleep here so correct me if I am wrong here but it looks to me like you are saving the publish date of the post each time you save the post,
$wr_event_end_date = isset($_POST['wr_event_end_date']) ? $_POST['wr_event_end_date'] : '';
$event_end_date = new DateTime($wr_event_end_date);
update_post_meta($post->ID, "event_end_date", $event_end_date->getTimestamp());
This -> $event_end_date->getTimestamp()
being the culprit.
So regardless of your variable $wr_event_end_date
value being set or not, your meta value is being assigned via getTimestamp()
because firstly there is no conditional statement that checks for the existence of your,
$_POST['wr_event_end_date']
which if FALSE
will instead revert to ''
(no value) which is then passed to your
new DateTime($wr_event_end_date);
Secondly, because
new DateTime( //is now empty here );
your
getTimestamp()
returns the current time stamp of the post.
#UPDATE#
UPDATE
You should still use the text_date
custom field, example:
array(
'name' => 'Test Date Picker',
'desc' => 'field description (optional)',
'id' => $prefix . 'test_textdate',
'type' => 'text_date',
),
...instead of using a timestamp especially if you have no reason to use a timestamp other than to convert it back to a regular date format because WordPress has inbuilt functions for handling date and time formatting.
Here is an example;
global $post;
$text = get_post_meta( $post->ID, '_cmb_test_textdate', true );
$text = date('d F Y', $text);
echo $text;
//prints 25 September 2012 for example
I've made sure to test this library to ensure it is in fact outputting results correctly and it sure is.