Using My-Meta-Box-Class plugin, how is ‘Date’ value stored?

I’ve created some custom fields in a custom post type using the my-meta-box-class plugin
which comes with a built in ‘date’ type of meta box input. I’m having a hard time ordering my custom posts by date. Is the date in this plugin stored as a strtotime()? If not, how can I slightly modify the plugin to get it to do so.
Is that even necessary?
Is there an easier way to order the events in my custom post type using what is already there in the plugin?

Related posts

Leave a Reply

2 comments

  1. It’s not really a plugin it’s more of a library/class the plugin file there is just to show off as a demo.

    any why when you call the date field you can set the format to a timestamp like this:

    $my_meta->addDate($prefix.'date_field_id',array('name'=> 'My Date ', 'format' =>'@'));
    

    you can see a list of valid formats here.

    and even better you can define your own validation function to store regular (literal text date) as time using php’s strtotime function like this:

    //create a class named at_Meta_Box_Validate with a method of validation
    if (!class_exists('at_Meta_Box_Validate')){
        class at_Meta_Box_Validate{
    
            public function date_str_to_time($new){
                return strtotime($new);
            }
        }
    }
    

    and then in your addDate function call that function like this:

    $my_meta->addDate($prefix.'date_field_id',array('name'=> 'My Date ','validate_func' => 'date_str_to_time'));