Title: text_time return empty, database contains right value
Last modified: December 15, 2017

---

# text_time return empty, database contains right value

 *  Resolved [Borneyak](https://wordpress.org/support/users/borneyak/)
 * (@borneyak)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/text_time-return-empty-database-contains-right-value/)
 * I have a problem with the text_time field type. I put the text_time into my simple
   plugin like the snippet below. I also added the text_date_timestamp. I used basicly
   the same kind of php code for both to get the info from the database. The date
   one gives me the right info and the time one gives me 00:00 back, while the database
   has the time info stored.
 * Setting up the metaboxes:
 *     ```
       $prefix = '_myevent_';
   
       $cmb->add_field( array(
                       'name'          => __( 'Date (start)', 'cmb2' ),
                       'id'            => $prefix . 'date_start',
                       'type'          => 'text_date_timestamp',
                       'date_format'   => 'j-m-Y',
               ) );
   
       $cmb->add_field( array(
                       'name'          => __( 'Time (start)', 'cmb2' ),
                       'id'            => $prefix . 'time_start',
                       'type'          => 'text_time',
                       'time_format'   => 'H:i',
               ) );
       ```
   
 * Showing the info:
 *     ```
       if (!empty ( get_post_meta( get_the_ID(), '_myevent_date_start', true ) ) ) {
                   $eventdatestart = esc_html( date("j F Y", get_post_meta( get_the_ID(), '_myevent_date_start', true ) ) );
               }
       echo $eventdatestart;
   
       if (!empty ( get_post_meta( get_the_ID(), '_myevent_time_start', true ) ) ) {
                       $eventtimestart = esc_html( date("H:i", get_post_meta( get_the_ID(), '_myevent_time_start', true ) ) );
                   }
       echo $eventtimestart;
       ```
   
 * What am i doing wrong? How can i get the time?
    -  This topic was modified 8 years, 6 months ago by [Borneyak](https://wordpress.org/support/users/borneyak/).

Viewing 1 replies (of 1 total)

 *  Thread Starter [Borneyak](https://wordpress.org/support/users/borneyak/)
 * (@borneyak)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/text_time-return-empty-database-contains-right-value/#post-9786391)
 * It’s solved. My mistake was that i used the php date() to return the time. That
   was not needed. Removing the date() solved my problem.

Viewing 1 replies (of 1 total)

The topic ‘text_time return empty, database contains right value’ is closed to new
replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Borneyak](https://wordpress.org/support/users/borneyak/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/text_time-return-empty-database-contains-right-value/#post-9786391)
 * Status: resolved