[英]How do I create a Y (year only) datetime field in Drupal 8?
Datetime module, Drupal 8: I want to create a datetime field with year granularity. 日期时间模块,Drupal 8: 我想创建一个具有年份粒度的日期时间字段。 In Drupal 7 , it was no problem. 在Drupal 7中 ,这没有问题。 Now in Drupal 8 , it isn't possible anymore. 现在在Drupal 8中 ,不可能了。 How can I create such a field without the Years Only module since it isn't safe? 由于不安全,如何在没有Years Only模块的情况下创建此类字段? Can I write a theme function? 我可以编写主题功能吗? If so, how do I do that? 如果是这样,我该怎么做?
Excerpt from the datetime.module: 摘自datetime.module:
/** * Defines the format that date and time should be stored in. */ / ** *定义日期和时间的存储格式。* /
const DATETIME_DATETIME_STORAGE_FORMAT = 'Ymd\\TH:i:s'; const DATETIME_DATETIME_STORAGE_FORMAT ='Ymd \\ TH:i:s';
/** * Defines the format that dates should be stored in. */ / ** *定义日期应存储的格式。* /
const DATETIME_DATE_STORAGE_FORMAT = 'Ym-d'; const DATETIME_DATE_STORAGE_FORMAT ='Ym-d';
This module is used to collect year part of date in any field. 此模块用于收集任何字段中日期的年份部分。 It provides a custom field type Year Only in the field UI. 它在字段UI中提供了一个自定义字段类型Year Only。
With the help of this module one can add field where he/she wants to get year only instead of complete date. 借助此模块,可以在他/她希望仅获得年份而不是完整日期的位置添加字段。
https://www.drupal.org/project/yearonly https://www.drupal.org/project/yearonly
Latest release on 24 October 2017, right after 2 days you post this question. 最新版本于2017年10月24日,在您发布此问题2天后。 So, it's not cover by Drupal. 因此,Drupal不在此范围内。
Hope it's help 希望对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.