简体   繁体   English

如何添加自定义Drupal日期格式?

[英]How can a custom Drupal date format be added?

How do you add a custom Drupal date format. 如何添加自定义Drupal日期格式。 I want to display the date without hours and minutes, but the options don't include it. 我想显示没有小时和分钟的日期,但选项不包含它。

Do the following: 请执行下列操作:

  1. Administration » Configuration » Regional and language » Date and Time 管理»配置»区域和语言»日期和时间

  2. There you will see a tab for format. 在那里,您将看到格式的选项卡。

  3. Create a new format string "YMd". 创建一个新的格式字符串“YMd”。

  4. Make this as your default for all date fields and you won't see the seconds any more. 将此作为所有日期字段的默认值,您将不再看到秒。

  5. You don't need the date module for basic formatting. 您不需要日期模块进行基本格式化。

Cheers, Vishal 干杯,维沙尔

Below is the image so that you know where it is. 下面是图像,以便您知道它在哪里。

Drupal日期和时间“格式”选项卡

You will see a button Add format in this path admin/config/regional/date-time/formats 您将在此路径中看到一个按钮添加格式 admin/config/regional/date-time/formats

Then, type your format there. 然后,在那里键入您的格式。 This will help you: http://php.net/manual/en/function.date.php 这将对您有所帮助: http//php.net/manual/en/function.date.php

After adding your format, you can choose in the tab Types 添加格式后,您可以在选项卡类型中进行选择

Oops. 哎呀。 I had this tab open in my browser for long time and didn't see the other answer. 我在浏览器中打开了这个标签很长时间没看到其他答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM