Skip to main content
Commonmark migration
Source Link

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.

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#

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.

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

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.

deleted 11 characters in body
Source Link
Adam
  • 16.5k
  • 1
  • 44
  • 62

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#

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', strtotime($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.

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#

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', strtotime($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.

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#

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.

added 968 characters in body
Source Link
Adam
  • 16.5k
  • 1
  • 44
  • 62

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#

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 = the_datedate('d F Y', strtotime($text)); 
echo $text;
   echo $text;

The following,

$text//prints =25 the_date('dSeptember F2012 Y');for example

...handles the formatting you.

http://codex.wordpress.org/Formatting_Date_and_Time

I've made sure to test this library to ensure it is in fact outputting results correctly and it sure is.

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#

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 = the_date('d F Y'); 
    echo $text;

The following,

$text = the_date('d F Y'); 

...handles the formatting you.

http://codex.wordpress.org/Formatting_Date_and_Time

I've made sure to test this library to ensure it is in fact outputting results correctly and it sure is.

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#

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', strtotime($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.

added 968 characters in body
Source Link
Adam
  • 16.5k
  • 1
  • 44
  • 62
Loading
added 417 characters in body
Source Link
Adam
  • 16.5k
  • 1
  • 44
  • 62
Loading
Source Link
Adam
  • 16.5k
  • 1
  • 44
  • 62
Loading