简体   繁体   English

如何在Drupal 8中创建Y(仅年份)日期时间字段?

[英]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.

相关问题 如何在LINQ查询中仅显示datetime字段的datepart? - How do I display only datepart of datetime field in LINQ query? 如何将只有一年(可能是字符串)的单元格转换为DateTime数据类型? - How do I convert a cell that has only a year (probably a string) into DateTime datatype? Codeigniter仅返回mysql datetime字段的年份 - codeigniter only returning year of mysql datetime field 如何获取Drupal 8中datetime对象的值? - How do I get value of datetime object in drupal 8? 如何从 Python 中的日期时间对象计算年份分数? - How do I calculate year fraction from datetime objects in Python? 如何将日期时间格式的列转换为仅一年? - How do I convert a column with datetime format to just a year? 如何编写仅匹配 DateTime 列的分钟字段的 Django 查询? - How do I write a Django query that matches only the minute field of a DateTime column? 如何编写仅查看日期时间字段的时间组件的activerecord查询? - How do I write an activerecord query that only looks at the time component of a datetime field? C#TableAdapter填写DateTime字段。 我该如何编辑,以便表格中仅显示时间 - C# TableAdapter Fills in with DateTime Field. how do i edit so only Time is shown in the table 如何在 python 中将日期时间格式 Year-Quarter 转换为 Quarter-Year? - How do I convert datetime format Year-Quarter to Quarter-Year in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM