pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

Date / Time field format not recognized #5038

Closed zu closed 1 year ago

zu commented 6 years ago

Issue Overview

Entry in a Date / Time field can't be recognised when using with Date Format Type "WordPress Default".

The Webseite is German and the with WordPress Default uses the monthname: j. F Y

Expected Behavior

Datetime value should be saved but won't.

Current Behavior

WordPress Default Format and Custom format produce error

What I try to enter

error

Possible Solution

WordPress Environment

``` Debug Information WordPress Version: 4.9.6 PHP Version: 7.1.17-1+ubuntu16.04.1+deb.sury.org+1 MySQL Version: 5.7.21 Server Software: Apache Your User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3451.0 Safari/537.36 Session Save Path: /var/lib/php/sessions Session Save Path Exists: Yes Session Save Path Writeable: Yes Session Max Lifetime: 1440 Opcode Cache: Apc: No Memcached: No OPcache: Yes Redis: No Object Cache: APC: No APCu: No Memcache: No Memcached: Yes Redis: No WPDB Prefix: lawp_ WP Multisite Mode: No WP Memory Limit: 40M Pods Network-Wide Activated: No Pods Install Location: /var/www/vhosts/lachevaline/releases/20180613125949/web/app/plugins/pods/ Pods Tableless Mode Activated: No Pods Light Mode Activated: No Currently Active Theme: lachevaline Currently Active Plugins: ARI Fancy Lightbox: 1.3.4 Disable Comments: 1.7.1 Duplicate Post: 3.2.2 Enable Media Replace: 3.2.5 GP Premium: 1.6.2 Gravity Forms: 2.2.5.21 Gridable: 1.2.2 Maintenance Mode: 2.4.3 Members: 2.0.2 Pods - Custom Content Types and Fields: 2.7.6 Recipe Custom Post Type: 1.0 Schema Pro: 1.1.3 The SEO Framework: 3.0.6 User Switching: 1.3.1 WordPress Importer: 0.6.4 WP Migrate DB Pro: 1.8.1 WP Migrate DB Pro CLI: 1.3.2 WP Migrate DB Pro Media Files: 1.4.9 WP Term Order: 0.1.4 ```

Pods Package Export (helpful!)

{"meta":{"version":"2.7.6","build":1528985021},"pods":{"1827":{"id":1827,"name":"kind","label":"Kinds","description":"","type":"taxonomy","storage":"meta","object":"","alias":"","fields":{"art":{"id":1830,"name":"art","label":"Art","description":"Standort, Markt oder Event","help":"","class":"","type":"pick","weight":0,"pick_object":"post_type","pick_val":"market","sister_id":"","required":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":"1","label_singular":"Kind","public":"1","show_ui":"1","hierarchical":"1","rewrite":"1","rewrite_with_front":"1","rewrite_hierarchical":"1","capability_type":"default","capability_type_custom":"kind","query_var":"0","sort":"0","built_in_post_types_aiosrs-schema":"0","built_in_post_types_custom_css":"0","built_in_post_types_customize_changeset":"0","built_in_post_types_generate_page_header":"0","built_in_post_types_market":"1","built_in_post_types_market_date":"1","built_in_post_types_oembed_cache":"0","built_in_post_types_page":"0","built_in_post_types_post":"0","built_in_post_types_recipe":"0","built_in_post_types_user_request":"0","built_in_post_types_attachment":"0","menu_location":"default","show_in_nav_menus":"1","show_tagcloud":"1","show_tagcloud_in_edit":"1","show_in_quick_edit":"1","show_admin_column":"1","pfat_enable":"0","pfat_run_outside_loop":"0","pfat_append_archive":"append","rest_enable":"0","read_all":"0","write_all":"0","menu_name":"Art","menu_location_custom":"7"},"497":{"id":497,"name":"market_date","label":"Market Dates","description":"","type":"post_type","storage":"meta","object":"","alias":"","fields":{"start_date":{"id":500,"name":"start_date","label":"Start Date","description":"","help":"","class":"","type":"datetime","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"0","datetime_type":"format","datetime_format":"dmy_dot","datetime_time_type":"24","datetime_time_format":"hh_mm","datetime_time_format_24":"hh_mm","datetime_allow_empty":"0","datetime_html5":"1","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","datetime_repeatable":"0","datetime_format_custom":"j. m. Y G:i","datetime_format_custom_js":"","datetime_time_format_custom":"","datetime_time_format_custom_js":""},"end_date":{"id":503,"name":"end_date","label":"End Date","description":"","help":"","class":"","type":"datetime","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"0","datetime_type":"format","datetime_format":"dmy_dot","datetime_time_type":"24","datetime_time_format":"h_mma","datetime_time_format_24":"hh_mm","datetime_allow_empty":"0","datetime_html5":"1","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","datetime_repeatable":"0","datetime_format_custom":"j. m. Y G:i","datetime_format_custom_js":"","datetime_time_format_custom":"","datetime_time_format_custom_js":""},"market":{"id":506,"name":"market","label":"– Market","description":"","help":"","class":"","type":"pick","weight":2,"pick_object":"post_type","pick_val":"market","sister_id":"509","required":"1","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":"1","label_singular":"Market Date ","public":"1","show_ui":"1","supports_title":"0","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"market_date","capability_type_extra":"1","has_archive":"1","hierarchical":"0","rewrite":"1","rewrite_with_front":"0","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","built_in_taxonomies_recipe-category":"0","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"1","pfat_run_outside_loop":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"0","read_all":"0","write_all":"0","menu_icon":"dashicons-calendar-alt","has_archive_slug":"termine","built_in_taxonomies_kind":"1","menu_position":"4"},"509":{"id":509,"name":"market","label":"Markets","description":"Market Venues","type":"post_type","storage":"meta","object":"","alias":"","fields":{"market_address":{"id":512,"name":"market_address","label":"Address","description":"","help":"","class":"","type":"text","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"city":{"id":515,"name":"city","label":"City","description":"","help":"","class":"","type":"text","weight":1,"pick_object":"","pick_val":"","sister_id":"","required":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"state":{"id":518,"name":"state","label":"State","description":"","help":"","class":"","type":"pick","weight":2,"pick_object":"custom-simple","pick_val":"","sister_id":"","pick_custom":"AG\/Aargau\nAR\/Appenzell Ausserrhoden\nAI\/Appenzell Innerrhoden\nBL\/Basel-Landschaft\nBS\/Basel-Stadt\nBE\/Bern\nFR\/Freiburg\nGE\/Genf\nGL\/Glarus\nGR\/Graubünden\nJU\/Jura\nLU\/Luzern\nNE\/Neuenburg\nNW\/Nidwalden\nOW\/Obwalden\nSH\/Schaffhausen\nSZ\/Schwyz\nSO\/Solothurn\nSG\/St. Gallen\nTI\/Tessin\nTG\/Thurgau\nUR\/Uri\nVD\/Waadt\nVS\/Wallis\nZG\/Zug\nZH\/Zürich","required":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""},"postal_code":{"id":521,"name":"postal_code","label":"Postal Code","description":"","help":"","class":"","type":"text","weight":3,"pick_object":"","pick_val":"","sister_id":"","required":"0","text_allow_shortcode":"0","text_allow_html":"0","text_allowed_html_tags":"strong em a ul ol li b i","text_max_length":"255","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","text_repeatable":"0","text_placeholder":""},"website_url":{"id":524,"name":"website_url","label":"Website (URL)","description":"","help":"","class":"","type":"website","weight":4,"pick_object":"","pick_val":"","sister_id":"","required":"0","website_format":"normal","website_allow_port":"0","website_clickable":"0","website_new_window":"0","website_max_length":"255","website_html5":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","website_repeatable":"0","website_placeholder":""},"market_dates":{"id":527,"name":"market_dates","label":"Market Dates","description":"","help":"","class":"","type":"pick","weight":5,"pick_object":"post_type","pick_val":"market_date","sister_id":"508","required":"0","pick_format_type":"single","pick_format_single":"dropdown","pick_format_multi":"checkbox","pick_allow_add_new":"1","pick_taggable":"0","pick_show_icon":"1","pick_show_edit_link":"1","pick_show_view_link":"1","pick_limit":"0","pick_user_role":[],"pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"0","rest_write":"0","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","pick_select_text":"","pick_table_id":"","pick_table_index":"","pick_display":"","pick_where":"","pick_orderby":"","pick_groupby":""}},"show_in_menu":"1","label_singular":"Market","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"market","capability_type_extra":"1","has_archive":"0","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"1","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"1","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","built_in_taxonomies_recipe-category":"0","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"0","pfat_run_outside_loop":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"0","read_all":"0","write_all":"0","menu_name":"Market","menu_icon":"dashicons-location-alt","menu_position":"5","menu_location_custom":"edit.php?post_type=market_date","built_in_taxonomies_kind":"1","sister_id":"506"}}}

Workaround or Alternate Solution Until Bug is Addressed

Use a format with no monthnames but only numbers.

Related Issues and/or PRs

quasel commented 6 years ago

Similar issue #4925 (I think)

and yes could reproduce that! (applies to all non English settings I tested)

quasel commented 6 years ago

Another one - #4814 but this time it's only about the output but I guess while you are at it…

atanas-dev commented 5 years ago

Just as an FYI, I spent some time today looking for a solution and wanted to share what I found:

  1. The crux of the issue is that submitted dates are in the current user's locale.
  2. Back-end validation fails since PHP date functions expect dates in English.
  3. Converting a non-English date string to a timestamp or another locale requires PHP's Intl extension or a third party library (strptime() does not behave consistently from environment to environment and is not implemented in Windows at all).
  4. Even if translated dates are validated correctly, they would still be stored in the current user's locale which will cause problems when you have multiple users with different locales so having a consistent storage format is a good idea (regardless of the input format).
  5. IMO, the solution would be to use a consistent format (like ISO 8601) when submitting and storing dates and use alternative formats for display and user interaction (e.g. through jQuery Datepicker's altField and altFormat). The downside is that you must know the field's configured format when displaying the value in the front-end, for example. This is pretty much the way WordPress handles post dates.
sandrine-rodrigues commented 2 years ago

The problem is still in Pods 2.8, with French date format, I cannot save the CPT, either with default Wordpress format, or custom (j F Y).

JoryHogeveen commented 2 years ago

Hi @sandrine-rodrigues

I created a new issue to bundle related issues together.

sc0ttkclark commented 2 years ago

Let's retest this after Pods 2.8.9 goes out as it has code that touches this logic.

sandrine-rodrigues commented 2 years ago

Still the same issue after updating to Pods 2.8.9....

image

image

JoryHogeveen commented 2 years ago

@sc0ttkclark This is a react / DFV issue, see: https://github.com/pods-framework/pods/issues/6389

fhcoding commented 2 years ago

Hi, I just solved this problem by enabling HTML 5 fields in the "Date Options". And the format is validatable by php and as I wish in the frontend.

trinermedia commented 1 year ago

Hi, I just solved this problem by enabling HTML 5 fields in the "Date Options". And the format is validatable by php and as I wish in the frontend.

Unfortunately, I cannot confirm this. I have also enabled HTML5 and selected "WordPress default (j. F Y)" as the format. The website language is German. The date output is still English.

JoryHogeveen commented 1 year ago

HTML5 doesn't support various formats. The format is based on your browser mostly. On the front-end it should change to the selected format depending on how you use the field. Our functions and magic tags all output the formatted value.

6860 fixed existing formatting issues with both the regular and HTML5 field and was merged into Pods 2.9.2.

Closing issue!

trinermedia commented 1 year ago

Ok, using the pods shortcode with the syntax for magic tags and the technique described here I could make it work. Thanks!