WPIntell

Source evidence

Change Requests

Date & Time Picker for Advanced Custom Fields · support · 2016-04-15T17:02:00+00:00

mixedsentiment
mediumseverity
0.72relevance
7replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 31 rows with source links

16.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

26 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Christoph Bratschi resolved
I would like to have the following features: 1) default value (current time) 2) timestamp in unix format Thanks, Christoph https://wordpress.org/plugins/acf-date-time-picker/ You can format the date and time using PHP date() function – please check FAQ for more details. For example, to display the timestamp you can use this code: echo date('U', strtotime(get_field('date_and_time_field'))); What about having a default value? Thanks, Christoph Do you mean the format set in the WP settings? This should work: echo date(get_option('date_format').' '.get_option('time_format'), strtotime(get_field('date_and_time_field'))); I mean if the user does not enter a value, the current date/time should be used. OK, I understand. But I don’t think this is a good idea to add this feature to the plugin (by the way: the built-in ‘Date’ field doesn’t return a default value as well). You can display the current time using the following code: if(empty(get_field('date_and_time_field'))) { // check if the field is empty echo date('Y-m-d H:i:s'); // or any other format } I am using a repeater field and need a way to attach a timestamp to each item. Therefore the actual date has to be stored. It is a newsticker. I will write my own plugin for this case. A simple input field is sufficient, I don’t need a date/time picker. In this case you don’t need to write a plugin – just use ‘acf/update_value’ action ( https://www.advancedcustomfields.com/resources/acfupdate_value/ ) and update the input field with the current timestamp.

Comments

7 shown
Bartosz Romanowski 2016-04-15T18:51:00+00:00

You can format the date and time using PHP date() function – please check FAQ for more details. For example, to display the timestamp you can use this code: echo date('U', strtotime(get_field('date_and_time_field')));

Christoph Bratschi 2016-04-18T11:49:00+00:00

What about having a default value? Thanks, Christoph

Bartosz Romanowski 2016-04-18T11:59:00+00:00

Do you mean the format set in the WP settings? This should work: echo date(get_option('date_format').' '.get_option('time_format'), strtotime(get_field('date_and_time_field')));

Christoph Bratschi 2016-04-18T12:10:00+00:00

I mean if the user does not enter a value, the current date/time should be used.

Bartosz Romanowski 2016-04-18T12:29:00+00:00

OK, I understand. But I don’t think this is a good idea to add this feature to the plugin (by the way: the built-in ‘Date’ field doesn’t return a default value as well). You can display the current time using the following code: if(empty(get_field('date_and_time_field'))) { // check if the field is empty echo date('Y-m-d H:i:s'); // or any other format }

Christoph Bratschi 2016-04-18T12:33:00+00:00

I am using a repeater field and need a way to attach a timestamp to each item. Therefore the actual date has to be stored. It is a newsticker. I will write my own plugin for this case. A simple input field is sufficient, I don’t need a date/time picker.

Bartosz Romanowski 2016-04-18T12:41:00+00:00

In this case you don’t need to write a plugin – just use ‘acf/update_value’ action ( https://www.advancedcustomfields.com/resources/acfupdate_value/ ) and update the input field with the current timestamp.