Questions tagged [datetime]

Use it for questions about handling date or time through any module. Don't use it if you are already using "calendar" as tag.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

Field gets unset and fails validation in user edit form

We have a special date field that we set upon user creation when our custom user form is submitted. The user does not have to set this field themselves. We have a separate form, which is a user edit ...
0
votes
1answer
20 views

Change default format for date field on user register form

I'm new to Drupal 8. In the user registration form, i've added a Date field via manage fields in user account settings. However, I need to customize this field and change its format. I tried 'manage ...
2
votes
1answer
26 views

In views, how do I show posts from this calendar day, ten years ago?

I have a view in which I want to display posts that I made on this date 10 years ago. I can get close but not exactly what I want by setting the view's filter to the following: "Authored On is ...
0
votes
0answers
16 views

Date difference with taxonomy field

I'm using D8 and I have a little problem with calculating age. I have a taxonomy term "Animal". It has a "name" and "date of birth" field. I have a content type "Test Results". It has a "date of ...
0
votes
1answer
29 views

How to display since when the node was created? [duplicate]

How to display since when the node was created with TWIG. Here is the templace of my node : <div class="card mb-5 p-0 overflow-hidden shadow rounded bg-white"> <div class="card-header ...
1
vote
1answer
51 views

How can I display the time passed since a comment was created instead of the creation date?

how to personalize my comments ? I want to display since when the comment was created instead of the date. I want to display the comment ID with the link "permalink". Can you help me ? Thank you ...
2
votes
1answer
42 views

How to Restrict views Date popup to only year/month

I want to have views exposed filter on node created field with popup. I've installed date_popup, the popup appears but I'm looking for a way to restrict it to only year and month. I tried the ...
-2
votes
1answer
29 views

I would like to create a field type “Time” [closed]

not within or as a date. If I use a number field, I'm not able to display a colon instead of comma or decimal dot. How would you solve this problem?
0
votes
0answers
48 views

how to convert a timestamp into a date format in a custom module [duplicate]

I created a custom module and printed this outcome in .csv. Name,Event,Email,Timestamp Ea Iustum Jus,Fifa,example@asdf.wer,1573924224 How do I convert the timestamp in a date format? I tried with $...
1
vote
2answers
58 views

How to change the date format in the date field as a select list?

On user registration page, I have added a date field in select list. In the manage form display tab, I can set the order of the dropdown fields like day/month/year or month/day/year But I am unable ...
0
votes
2answers
49 views

How do I programmatically save “2019-11-04 07:30:00+01”?

I have "2019-11-04 07:30:00+01" as datetime value. I am not getting how to handle the "+1" part in a Drupal 8 date field. I am using this code, but it's not giving me any value. use Drupal\Core\...
0
votes
1answer
24 views

Combining Date Start and Date End in Drupal 8 Views Block

I am new to Drupal 8 Views - How do you concatenate Event Start Date Sept 1, 2019 with Event end Date ie: Sept 4, 2019? The end result is they just want the Month and Day to show up like this Sept 1-4....
0
votes
1answer
134 views

Views date exposed filter by year in checkboxes

I have date field. In views I want to add the a date exposed filter. This filter will only display year and we can select multiple years. Just like this I have checked the better exposed filter ...
0
votes
1answer
45 views

Filter excludes date in end date field

I have a view in Drupal 8 as below. [The date column in below list, is not an event. its order item. so date showing is order complete date only] When I filter with start and end date, the data shown ...
0
votes
0answers
43 views

How to show date as “XX ago” (only two digits) in comments/node/taxonomy/blocks? [duplicate]

This code works for comments but I need to display the date in two digits (XX minutes, XX hours, X year) not as "XX hours XX minutes" for example. And I need to apply this format for the rest of the ...
-2
votes
1answer
300 views

Calendar/datepicker popup not working on safari

Below is the date type form field I have in some form which renders on chrome correctly. $form['date']['air_date'] = array ( '#type' => 'date', '#title' => t('Air Date:'), '#required' =&...
0
votes
0answers
35 views

Views exposed date filter range format

I have a view with an exposed filter for a date range. I use jquery ui datepicker to select dates. It works good and I can select dates in spanish format (dd/mm/yyyy). But when I apply the filter, It ...
1
vote
0answers
27 views

Instantiate DateTime with localized time [duplicate]

I'm trying to migrate some data from MySQL DateTime format. Here's one: $old_date = "2019-05-06 08:00:00" My content type has a custom field using DateTime. Using the info from SO links below, I ...
3
votes
1answer
87 views

Date input format problem

I need to import a large dataset (over 300,000 records) into a Drupal 8 site. I have figured out how to do this with feeds on a small test dataset. The dates in the records are in the format June 8, ...
0
votes
0answers
19 views

How to refer to the node created date in Computed Field PHP

I am using the Computed Field module in D8. I am trying to compute some dates using the node created date as the start point. As my first try, this code works: $valuein = $entity->field_datefield-...
0
votes
1answer
282 views

Format date field in twig

Date field having multiple values. Need to format the output. {% for item in items %} <div{{ attributes }}>{{ item.content|date(format="F j, Y") }}</div> {% endfor %} item.content ...
0
votes
1answer
30 views

How do I create a time range form field?

Is there any way to add time range input fields in a form, for example using code similar to the following one? $form['notification_hours'] = array( '#type' => 'time_range', // type time_range ...
-1
votes
1answer
146 views

Get difference between two dates programatically

In summary: On a Drupal 8 project, i am trying to programatically get the difference between two different times (current time - Node creation time) Use case: I have "nodeabc" already available on ...
0
votes
1answer
34 views

Filter a view with contextual authored date

I have a Drupal 8 view where I want to sort nodes by authored year using contextual filters. So www.mysite.com/2017 will list all nodes from 2017. I set up the filter using 'Content: Created Year' ...
1
vote
1answer
35 views

Upgrade breaks Rest Export View in Calendar [closed]

We have a website that uses Views with a serializer rest export to display events on a monthly calendar. When we upgraded from 8.6.16 to 8.7.3 the calendar display is blank. All the json information ...
0
votes
0answers
29 views

Drupal Event Calendar module - Can I make the end time of an event dependent on another field?

I am using the Event Calendar module to create "music classes" for a school of music. They have three levels of classes: Beginner - each class is 30 minutes long Intermediate - each class is 40 ...
0
votes
0answers
18 views

How to declare field type DATETIME and set the default value

I have a problem but with the following code. I am creating the following Schema: $schema['billfold'] = [ 'description' => 'Stores example person entries for demonstration purposes.', '...
-2
votes
1answer
70 views

Can I use Moment.js to fix a client side date format issue?

Different Browser and OS show a different date format on client side. Given the following markup: <input data-drupal-selector="edit-field-date-end-value-date" title="Date (e.g. 2019-05-15)" type="...
1
vote
0answers
47 views

How to create a pair of dates (date_combo) using the Form API?

The Date module provide a field type called date_combo that allows a date feld to collect both a start date and an end date. It works as expected when I use the GUI to create a content type with a ...
0
votes
0answers
15 views

How do I use the DateFormatter? [duplicate]

I am trying to use the DateFormatter so I can convert my unix time-stamp into a usuable date stamp that will be set on a custom form. This is my code: $time = \Drupal::time()->...
0
votes
1answer
42 views

How to use date_date_callbacks

In Datetime.php from Core\Datetime\Element, I read: #date_date_callbacks: Array of optional callbacks for the date element. Can be used to add a jQuery datepicker. What does it mean? How am I ...
-1
votes
2answers
695 views

Convert current time from Unix timestamp to date format (d/m/y)

In my custom module (.module) file, I am using: $current_time = \Drupal::time()->getCurrentTime(); date_default_timezone_set('GMT'); to get the current date... However, the date value is returned ...
0
votes
0answers
18 views

How to order datetime items chronologicaly on save

Is there a module or a simple way to order a multipe datetime/datetime_range field chronologicaly on every save? I want to be sure that the last item is always the last one.
0
votes
2answers
102 views

Date/Time not saved correctly?

I made a date range field, and after entering some values and saving on first glance it looks ok, if i entered 20:00:00h it will display the same, but in the DB when i look at the stored values it's -...
0
votes
0answers
23 views

How to restrict dates in the form widget?

I am attempting an upgrade and I am looking for something that mirrors the functionality of the Date Restrictions module Basically, I used it to set relative limits,, something like no earlier than ...
2
votes
1answer
51 views

No default value for '#type' => 'date'?

is there a way to configure a date form so it has no default value? Setting the default value to NULL sets the default value automatically to the current date. /** * @return array */ public ...
0
votes
1answer
28 views

custom module date formatter for publication date

I have a Drupal 8 contrib module AP Style Date that provides a formatter for dates to conform to the AP Style Guide date rules. When using the module Publication Date, this formatter does not come up ...
0
votes
1answer
33 views

Rules add date variable from webform submission

I have a webform where the user also submits date. I would like to populate a date type field with the submitted date. I tried making variable by "Add variable", but I do not know how to access my ...
2
votes
2answers
683 views

Date vs Timestamp field-type

My new project involves the requirement of manually setting a time of creation of nodes because they're looking into manually migrating parts of their old website into their new one. The date will ...
0
votes
0answers
92 views

Why is a ISO:8601 date within a time tag converted to zeroes?

I've been attaching Timeago script to my themes and it requires dates to be formatted like this. <time class="timeago" datetime="2008-07-17T09:24:17Z">July 17, 2008</time> In a view, I ...
0
votes
1answer
169 views

Upon submitting a webform, set a date field on the article node equals to “current time” + “X minutes”

I am using the Field Timer module to display countdown timer on my article node. This module will take the value of the date/time field (my case: field_article_datetime) and convert it into a ...
1
vote
1answer
287 views

Set a date field equal to “current time” + “5 minutes” using tokens

I am using the Field Timer module to display countdown timer on my article node. Say my article node has the date/time field named (field_article_datetime) This module will take the value of the ...
1
vote
1answer
35 views

How to show the following n events with respect to the current date or the past events to always ensure n elements in the view?

I have an agenda on my homepage, and I want to always ensure 5 events. If there are 5 or more following events (including the current one), show the nearest 5 from the start date. If there is less, ...
0
votes
1answer
37 views

Serializing dates

In Drupal, we have the time printed as "2012-03-19 07:22". What I need is just "\/Date(1198908717056)\/" or just "1198908717056". I am trying to get that format using the following code. use Drupal\...
1
vote
1answer
62 views

Create Custom Date Formatter for Date Posted Field

I followed a very helpful article by Antonio Benitez that gave some example code showing how to create a custom date formatter for date fields (How To Create a Custom Format for a Date Field). The ...
1
vote
2answers
576 views

Control Webform's date field (datepicker) from JS

I have to change number of months that's shown in datepicker of my date field in Webform, on desktop I need 2 months, but on mobile just 1. I'm not able to control that using JS, so I created patch ...
0
votes
0answers
130 views

How to combine two date fields and alter its value programmatically based on field value?

I have two fields field_start_date and field_end_date and under manage display section I have set the field format for field_start_date as F d field_end_date as - d Y I need to combine the two fields ...
0
votes
1answer
43 views

Datelist element in webform not working

I was just going through webform configurations and I changed the date list element format from default to raw. After doing this Im not able to add any element of type dateform to my webform and also ...
1
vote
0answers
24 views

How do I access datetime field formatter node values?

The DateTimeFormatterBase class is performing a ->setTimeZone incorrectly for my use case. How do I access the node values from where the $date passed to setTimeZone originated? Strange question I ...
0
votes
0answers
17 views

Copy Field Collection Data to Date Range Fields?

When our Drupal 8 website launched we used the Field Collection module so that some content types could store two or more dates for calculating a range, something not then supported on the platform. ...