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
1answer
18 views

Filter nodes by today's date

Following what described in Views filter criteria date field is greater than current date, I have used operator >= today with some success. I would like to create "future" nodes and they should be ...
0
votes
0answers
10 views

Are there any solutions that integrates custom mysql datetime field with views?

I created my own table with a mysql datetime field via hook_schema. The code that defined the field is here 'timestamp' => [ 'description' => 'The timestamp value when the recipient ...
0
votes
1answer
36 views
+50

How to limit form submission per user per day and week?

The goal is very straightforward. I need a form to limit each user to 1 submission per day and 3 per week. What I found: Webform: The "Form settings" in webform has the "Per user submission limit" ...
0
votes
0answers
44 views

Date range issues with timezones in twig

We're using date ranges for some events in an application. We're finding that when we use the date value and end_value independent of one another then the timezone is incorrect. For example, inside a ...
0
votes
1answer
35 views

How to translate the month name in a date select list field?

I have created a date field in user account fields. In manage form display, I have selected Select list as widget. I want to translate the month names which is displaying a select list. I checked it ...
0
votes
1answer
38 views

How to display date and time picker for base field on custom entity

I've made a base field on a custom entity with type "datetime" using "datetime_default" for the form display. It's displaying as only a date picker, with no time component, whereas I want it to look ...
0
votes
0answers
23 views

Full node shows a different datetime(hour) value than the same field in a view

I have a content type with a "date and time" field. I have populated this field using core json post using this format 2020-02-19T13:25:00. This works good and field is filled. When I add this field ...
0
votes
0answers
20 views

How to update default value of a datetime field?

I have a content type 'News' with a datetime field. I'm trying to alter its default value depending the choice of another field. So, i added some AJAX in the form : <?php /** * Implements ...
0
votes
0answers
20 views

Render date in the correct timezone

I'm trying to display render the "event" day in my custom tpl. I save in that node 31/01/2020 - 20:30 If I check the table (this is a field collection), the value stored is 2020-01-31 19:30:00 ...
0
votes
0answers
39 views

How to display date range facet filter in Drupal 8?

I am using a date range field in my content type. I have installed search api and facets modules. In the node index, I have selected the Date range type for the date field. I have created a facet ...
0
votes
0answers
21 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
53 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
51 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 ...
-3
votes
1answer
31 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
105 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
60 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
25 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
257 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
49 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
47 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
712 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
43 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
103 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
22 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-...
1
vote
1answer
366 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
34 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
230 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
46 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
20 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
97 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
51 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
49 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
886 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
136 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
53 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
29 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
35 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 ...
3
votes
2answers
880 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
96 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 ...

1
2 3 4 5
24