Date, Date and time, and Time
3 min read
The three date and time types store real DATE, DATETIME and TIME values, so the database can sort and compare them ("events after today").
Type | Type id | Column | Allowed SQL types | Stored and returned as | Control |
|---|---|---|---|---|---|
Date |
|
|
|
| Browser date picker |
Date and time |
|
|
|
| Browser date and time picker |
Time |
|
|
|
| Browser time picker |
The controls are the browser's own (<input type="date">, datetime-local, time), so the look and the calendar depend on the editor's browser and language.
Type settings
Setting | Default | Effect |
|---|---|---|
Display format | empty | A PHP date format used when the value is printed ( |
The format affects output only. wpmcf_get_field() always returns the stored string.
Values are site time
Dates and times are wall-clock values of your site's timezone. No timezone conversion happens when saving or reading. A Date and time of 2026-05-01 08:30:00 means 08:30 in the timezone set in Settings › General. Printing uses WordPress's wp_date(), so month and day names follow the site language.
What is accepted when saving
Parsing is strict: the value must match one of the accepted formats exactly and be a real calendar moment. Anything else is dropped and the field is saved empty.
Type | Accepted input | Saved as |
|---|---|---|
Date |
|
|
Date and time |
|
|
Time |
|
|
Refused examples: 2026-02-30 (no such day), 01/05/2026 (wrong format), 2026-05-01 10:00 for a Date, 2026-13-01 08:30, 25:00, 8:30 (the hour needs two digits), and a date without a time for Date and time. A refused value clears the field; it does not keep the previous value.
Default value and timestamps
- A default value must be a complete value in the column format (
2026-01-01,2026-01-01 09:00:00,08:30:00); otherwise the group is refused ("the default value does not fit this field type (dates are YYYY-MM-DD, times HH:MM:SS)"). - Date and time can use the column function
current_timestamp: when the field is left empty the database fills in the current moment as the object's row is created, and an empty submission later leaves the stored moment unchanged. It is a "when was this first saved" stamp, not a "last modified" one.
Template usage
$date = wpmcf_get_field( 'event', 'starts' ); // "2026-05-01" (string) or null
$time = wpmcf_get_field( 'event', 'doors_open' ); // "19:30:00"
if ( $date ) {
$moment = DateTimeImmutable::createFromFormat( 'Y-m-d H:i:s', $date . ' 00:00:00', wp_timezone() );
echo esc_html( wp_date( 'l, j F Y', $moment->getTimestamp() ) ); // Friday, 1 May 2026
}
wpmcf_the_field( 'event', 'starts' );
// With Display format "d/m/Y": <span class="wpmcf-field-value">01/05/2026</span>
// Without a format and a "F j, Y" site date format: May 1, 2026[wpmcf_field group="event" field="starts"]
[wpmcf_field group="event" field="starts_at" wrap="false"] → May 1, 2026 8:30 amBecause the stored text sorts correctly (2026-05-01 before 2026-05-02), you can compare it as a string in PHP and filter on it in queries. See Developer API for wpmcf_query_posts().
Import
CSV imports accept the strict formats above and also anything PHP's date parser understands (for example 1 May 2026 or 05/01/2026), read in your site's timezone.
Troubleshooting
- The date prints in the wrong format. Set Display format, or change the date format in Settings › General.
- A date I typed in the browser did not save. Browsers submit
YYYY-MM-DD; if the value came from your own code, use the same format. - Midnight shows as 12:00 am. That is the site's time format. Set a Display format such as
H:i. - The Date and time field is empty on new posts although I want "now". Set the
current_timestampcolumn function (it fills the value when the row is created), or set the value in code on save.
Still stuck? Contact support