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
0 answers
12 views

How to modify the timezone options list?

I have a date range field in a paragraph which is set to allow setting the timezone. Can someone suggest how I can alter the list of options used to select the TZ? For the user profile form a simple ...
  • 1,014
1 vote
0 answers
44 views

How to calculate the sum of duration in a view?

How to calculate the sum of duration in a view ? I would like to know the total duration of an album after having entered the duration of each track on the disc. I use the Duration field and Views ...
  • 21
1 vote
1 answer
35 views

using hook_form_alter() to change year range of datetime select widget, with deltas for multi-value fields

I have multiple date fields on a node form for which I am using the select widget. The year select list has a range of years that is far too wide for our purposes (1900-present), so we want to limit ...
0 votes
0 answers
18 views

Date filter not working with start date

I wish to filter view for node type 'event' by start date > today, or alternatively by >= YYYY, if relative date is not possible. Neither is working. The view SQL see below doesn't apply the ...
0 votes
1 answer
98 views

Alter DrupalDateTime Timezone To Correct the Timezone

I have a situation where I need to conditionally correct the default timezone defined in a drupalDatetime object. But I'm clearly not understanding how to do it properly. Example: use Drupal\Core\...
0 votes
0 answers
21 views

Tracking time on custom form module

I have developed a module that presents a custom form in a page. I want to count the time from the moment the user is on the content url. There is a pause button that takes the user back to the start ...
  • 1
3 votes
3 answers
816 views

DrupalDateTime::createFromFormat() returns the wrong time value

I want to get the date of last monday at 00:00:00 in a specific timezone. When I try this: DrupalDateTime::createFromFormat('U', strtotime('last week monday'))->setTime(0, 0, 0)->setTimezone(new ...
  • 27.2k
0 votes
0 answers
6 views

Group rows by date

In a custom view, I have some values which belong to the same month (06/2022). If I have some other data, they will be also displayed (before or after the 06/2022) How can I change the configuration ...
  • 79
1 vote
0 answers
47 views

How to write time range condition for datetime field?

I need a query that will show events only in specific time range. For an example: Event 1 -> 2022-06-12T20:00:00 Event 2 -> 2022-06-11T11:00:00 Event 3 -> 2022-04-12T09:00:00 Event 4 -> ...
0 votes
1 answer
137 views

How can I update the node date for all nodes

I have imported a number of nodes to a fresh installed Drupal 9. Later, the original content creation date (from the previous website) became important. I have the information according to the new ...
  • 15
0 votes
1 answer
33 views

Cannot get entity form to display date field value

I have an entity with two date fields. In the code that saves the entity, is: $date_requested = date('Y-m-d', time()); and in the list of field values that get added to the entity: ->set('...
0 votes
0 answers
13 views

Results from "end date" in date range excluded from Views results [duplicate]

I have a view of Commerce orders, and I need to add an exposed filter to filter the orders by date range. I have added two exposed filters for Order: Placed. One filter is "greater than or equal ...
  • 1,234
0 votes
0 answers
96 views

Drupal Views filter on a Date field does not work as expected

I have a Drupal7 view which includes a field of Date type (let's say "activity date") via a relationship. I want to filter this field by "today" (show only activities with activity ...
  • 121
0 votes
0 answers
25 views

How do I convert custom entity's created timestamp to date format on save to database for filtering by date in a View [duplicate]

I am using Drupal 9 I have a custom entity which I am using to log some events. In my view, I wish to add a filter to retrieve entities created between two dates. My view displays the date as dd-mm-...
  • 1
1 vote
1 answer
1k views

Can't seem to format date in twig from UTC to User's locale

I am trying to format the date field from an event content type that I've created so that I can pass the date into an event exporter that creates events in calendars such as Google, Apply, Yahoo, and ...
1 vote
1 answer
607 views

how to convert date into timestamp using timezone

I am using strtotime to convert date into time stamp but its does not work correctly. I know its relatively to time zone. My drupal store time zone is denver. I am not sure why its not showing correct ...
1 vote
1 answer
48 views

Is there a way to limit the time zones available to the user to select from?

We have a Drupal 9 site that has a Smart Date field with Time Zones. However, the time zone selection list is huge. We want to limit it to the four main US times zones. Is this possible?
  • 1,093
2 votes
0 answers
36 views

old dates in datetime field

I need to be able to enter old dates. I am not allowed to enter anything prior 1880. Using drupal 9, datetime field. Daterange does not allow to enter anything before 1900. Any workaround or solution?
1 vote
0 answers
68 views

Can't save value of custom datetime field

I'm reaching out because I just can't find out why my custom datetime field isn't saving its value after I submit. Context: I've created a field containing two datetime fields. I will use it to add or ...
  • 11
-1 votes
1 answer
48 views

Migrating date into drupal datetime field

i am having the xml selector <starting_date><![CDATA[ 2017-01-01 22:34:56 +0100 ]]></starting_date> this migration process fails : process: field_job_starting_date: plugin: ...
  • 3,111
1 vote
1 answer
61 views

Custom field formatter fails in create()

PHPStorm, PHP 7.4 IDE highlights $container->get('date.formatter'), with "Expected parameter of type '\Drupal\Core\Datetime\DateFormatterInterface', 'object' provided" This function is ...
  • 21
2 votes
0 answers
69 views

Is there a way to restrict time zone options in the DateTimeRange field widget?

Is there a way to limit the options of the timezone field in the datetime or datetime range widget in Drupal 8? It currently shows tons of timezones, but we really only need about 10 options. I ...
  • 27.2k
0 votes
1 answer
234 views

Filling in default value for datetime field in custom entity

I am trying to set the default value for the date field in a custom Entity. The code does not produce any errors. The date field does just not populate with any value. How can I set the default value? ...
1 vote
0 answers
68 views

Programmatically set a views filter value on page load (not contextual filter)

I have created some views for an Events content type with field_start and field_end timestamp fields. One of the displays is for 'Upcoming Events'. I want to filter only those events whose start date ...
-1 votes
1 answer
111 views

How can i change dateformat of webform submission

Is there a way where we could change the date format of the form submission? For Example in the Webform I have created there's no date picker in it. But when the web form is submitted by the user by ...
1 vote
0 answers
16 views

Adding a relative date range facet to a Search API view using the "last updated" field

I would like to add a facet to a search_api view filtering on the content "changed" field. I would like to use friendly naming like "This week", "This month" etc. There ...
  • 874
1 vote
2 answers
3k views

How do I compare a date field with the current time in a twig template?

I have a date field on a node – set to a custom date format (c which is ISO) in the Manage Display. I have a twig template checking to see if that date field comes before today, in which is should ...
  • 13
0 votes
1 answer
698 views

Views exposed filter by season from date field (date range group as month only?)

How would I create an exposed filter by season (spring, summer, fall, winter) based on date fields? I figured the approach would be to create date range filter groups by MONTH only (no year), but I ...
  • 76
1 vote
2 answers
1k views

How to change date format in the webform date element?

I have added a date element to my webform. Now I want to change the date format for the date element. I have used the following code. function my_module_webform_element_alter(array &$element, ...
  • 2,765
1 vote
1 answer
24 views

View based on months or days - display certain items during specified times of the year

I am trying to create a calendar-type view that will display links to specific nodes during certain months of the year. For example, this would show 'Taxes' in Feb and April, 'Travel' from May to ...
1 vote
1 answer
177 views

Exposed date filter against >= "today" fails until 5pm Mountain time

I added a Date only date field named expires to the user profile. The expires field has the value 2021-01-08 for a certain user (I checked the database; it has no time component). In a view, I have an ...
2 votes
1 answer
389 views

Migrate date time field using migrate source csv

I am trying to migrate a datetime field from csv file but only few are being migrating and other are being failed.I am using migrate I have created two datetime fields called as Activation Date and ...
0 votes
0 answers
80 views

How does core handle the different time zones?

Here is my situation, I have a website where the content author(i.e who has his preferred time zone as PST in US) had created the node of one content type which had an event in New York(i.e a ...
  • 11
1 vote
0 answers
55 views

Filter nodes that have a field date that is not in the future

I have a view setup to list nodes that have "public date" date field that are in the past. To do that, the filter is doing a Content: Field Public Date <= today. "today" if the ...
  • 27.2k
0 votes
0 answers
63 views

Relative date filter views block is cached for anonymous users

Drupal 7.74, views 3.24 (latest) I have a view which uses a date field to filter and shows on: less than or equal to "now" I display the view in a block. With caching for anonymous enabled, (...
0 votes
2 answers
88 views

Display multiple timezone values from a single date/time entry

In Drupal 7 Views Date/Time field, is there a way to generate multiple timezone values from a single event date, with start and end values? For example, if an event is entered into the start/end Time ...
0 votes
0 answers
64 views

How to accept multiple date formats for date field in webform module (with and without leading zeros)?

I have webform created with webform module. Inside it I have date field which should accept person's date of birth. When I edit that filed I can set date format at "Date settings" section, &...
  • 485
-2 votes
1 answer
51 views

How do I display only products that do not exceed the end date?

I created in my product type, a "Date interval" field. I created a view that contains this field. With a start date and an end date. I want my view to show only products that are within the ...
  • 1
1 vote
2 answers
810 views

How do I migrate dates?

In my Drupal 7 site, the date is stored in the database as 2020-08-10 00:00:00. When I migrate those dates without any formatting (field_blog_post_date: field_blog_post_date), the date is migrated ...
  • 3,196
0 votes
1 answer
55 views

Changing existing date time field

I am working on an already existing site that has content. There is a content type with field date and time. I need to remove the time component and just be Date only without deleting any content ...
1 vote
1 answer
601 views

How can I change the date format for user submitted data in confirmation emails

The confirmation emails sent by webform (running under Drupal 8.9.7) on submission are in the USA format (m/d/Y) for all date fields submitted by users on the form, differently from the system ...
1 vote
0 answers
130 views

Posting date when a submission is made

I am a newbie at Drupal, so apologies if I am missing something obvious. I searched the issues with various keywords but could not find a similar problem. I need some data to be sent via remote post ...
3 votes
1 answer
742 views

Date Field Type - Text Field Widget is Gone?

I am noticing that the Date field type only has the availability of three widgets: Select list Date and time Select list, no time Can someone tell me why the "Text Field" widget is gone? ...
0 votes
1 answer
265 views

In Views, when using a filter on a datetime field, what is the time zone of the offset?

When I use an offset like "-4 hours" in a Views filter on a datetime field, which timezone is used? More details In Views, when I add a filter for a datetime field, I get the following ...
0 votes
0 answers
170 views

Date time save in database

I have two very basic vanilla installation of Drupal 8. One I have installed a few months back, and one I installed today. I have an identical datetime range field in both of them. But I noticed that ...
1 vote
1 answer
169 views

How do I translate the weekday in a date?

I created a view from a JSON file; the dates in that file follow the 2020-07-28 20:00 format. I do a rewrite of the date to <span>{{ value_1|date("l d/m/Y") }}</span> and I get ...
0 votes
0 answers
722 views

How do I change the date format of a date field?

How to change date format of date field? I'm using webform module. There is no date format field to set it. Also read somewhere that changing default date format of "short" format will do ...
  • 485
1 vote
1 answer
197 views

How can I show a date in Urdu?

I am working on printing dates in more than a language. With Drupal 7, I used the following code. <span class="arabic-date"> <?php $arrayurdudays = array('', '', '', '', '', '', ...
0 votes
1 answer
68 views

Why doesn't my date get rendered?

In Drupal 8, I have a Flag entity with a date field attached. My code looks like this: function MYMODULE_flagging_presave(FlaggingInterface $flagging) { if ($score == 0 || $score == 1) { $...
0 votes
0 answers
45 views

Filter view results by "created"/"authored on" date - shows all content regardless of post date

I've been throwing myself at this for a while, apologies if I've missed anything stupidly obvious. I'm trying to create a table of statistics for content submitted by all users (using Views Aggregator ...
  • 1

1
2 3 4 5
25