Date field

Note: there is a newer and better field called Date- & Timepicker field.

Let the user select a date from a date picker.

Return value

Returns the selected date as a string in format is dd-mm-yyyy.

If no date is selected an empty string is returned.

Extended Return Values

Returns an array with for example the selected date format in WordPress.


$selected_date = simple_fields_value('dateExample');
echo "Your selected the date $selected_date";


You selected the date 29/08/2012


Internally the date field stores the date in the format dd-mm-yyyy, which is far from perfect when it comes to sorting. If you need to sort posts based on date values from this field type then please see this question over at WordPress Answers.

The more up to date Date and Time Picker stores it’s values in ISO 8601-format, that is very easy to sort on.

4 thoughts on “Date field

  1. Jared Meit

    In an upcoming version, could you add a line, after the opening of init_simple_fields_field_date_v2(), that sets the timezone to what is set in the wordpress settings? It would be good because my webhost is set to a different timezone than the location that my site is for.
    I used this line, and it seems to work perfectly well:
    date_default_timezone_set( get_option( ‘timezone_string’ ) );

    Thank you.

  2. Jared Meit

    Thank you! That works perfectly. Such a quick response too.
    I noticed one more thing here. The timestamp isn’t taking into account the timezone that I set in WordPress. It’s using my server’s timezone, which is not the same as mine (Toronto), because I use a shared-hosting server. So, I had to insert date_default_timezone_set(‘America/Toronto’); right before running the simple_fields_value(“event_date”, $event->ID);.
    It would be great if you could somehow get the timezone that is set in the WordPress Settings.

    I love your plugin and use it in all of my WP projects. Thanks again for the quick response. I will be donating to you now, for sure.

  3. Pär Thernström Post author


    Sorry but extended values are not available right now for the simple_fields_get_post_value. Seems like I forgot it when I did all the new functions and features. :/ I will get this fixed in the next version.

    Meanwhile, there is a quick way for you to get extended values working:

    * Add a slug to your field. You do this in the simple fields field grop settings.
    * Then use the function simple_fields_value() instead to fetch your value:
    $eventDate = simple_fields_value($event->ID, “yourEventDateSlug”);

    Hope this helps!

  4. Jared Meit

    I have Extended Return Values AND timestamp turned on, and it still only gives me the ‘saved_value’ part of the array.

    Here’s how I’m trying to use it. Let me know if I’m doing something wrong.
    $event = get_post( $args );
    $eventDate = simple_fields_get_post_value($event->ID, “Event Date”, false);

    Then, print_r displays this: Array ( [0] => 25/11/2012 )

Leave a Reply