Date and Time Picker

With the date and time picker field you can show a a date picker, time picker, or a picker with both date and time to the user.

The saved values are stored in the database in ISO 8601-format , so the saved dates should be fine to sort when using for example WP_Query.

Screenshots

Return Values

An array will lots of useful info about the selected date and/or time. The returned values are different depending on if you show a date picker, a time picker, or a date and time picker.

Below is an example output with all 3 combinations used:

Code examples

Get saved date/time


$date = simple_fields_value("myDateSlug");
echo "The concert is scheduled for " . $date["date_format"];

Output of above

The concert is scheduled for November 3, 2012

Get posts orded by saved date


// Gets all posts from a custom post type called "calendar"
// that has a simple field of type date&timepicker
// the older event comes first, and the newest (possible in the future!)
// comes last
$query = new wp_query(array(
"post_type" => "calendar",
"posts_per_page" => -1,
"orderby" => "meta_value",
"meta_key" => "_simple_fields_fieldGroupID_1_fieldID_1_numInSet_0",
"order" => "asc",
"meta_query" => array(
// only include dates that are today or in the future
array(
"key" => "_simple_fields_fieldGroupID_1_fieldID_1_numInSet_0",
"value" => date("Y-m-d"),
"compare" => ">="
)
)
));

Syntax for simple_fields_register_field_group

2 thoughts on “Date and Time Picker

  1. mikmik

    I’m trying since yesterday to change the color of the date square when active (wanted a brighter color ), the css seems to be in a jquery library, so i searched the link in the plug-in files to change it or try to customize via jquery libraries but i didn’t found it anywhere. Is there a solution to solve this problem ?

Leave a Reply