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

How can I change datetime field to date field?

I have a Drupal site successfully migrated from Drupal 6 to Drupal 10. Some date content type fields were changed during migration from date format to datetime format by mistake. Drupal's admin > ...
Robert Zelník's user avatar
0 votes
0 answers
11 views

Using Rules to calculate end date based on start date

I have a reservation content type with field_start_date that the user sets for staying. Users can update this node at any time. I want to be able to: Calculate the field_end_date based on the proposed ...
user3532287's user avatar
0 votes
1 answer
29 views

Rules Action 'Set a data value' of a DateTime with CurrentDateContext is not using UTC date

I am having a hard time finding documentation on this. I have a Date and Time field (field_start_time) in a Drupal 10 ECK Entity (wo_time_clock). I found that it is saving the date and time in ISO ...
tawellman's user avatar
2 votes
0 answers
21 views

jQuery timepicker on custom FAPI form element

How can i add jQuery timepicker to custom form element. There is some description on API docs: #date_time_callbacks: An array of optional callbacks for the time >element. Can be used to add a ...
Ev Tr's user avatar
  • 21
0 votes
2 answers
82 views

How do I change the input type created by views daterange filter?

I am using a view created with the views module. The view displays all change requests, and I wanted to expose a filter to users to be able to filter the change requests by date. The change requests ...
GeorgeCiesinski's user avatar
0 votes
0 answers
16 views

Rango de fechas: this field cannot hold more than 1 values when I try to sync content to a node with a date range field

I'm working with Feeds to sync content from a JsonAPI resource. Everything works fine except the date range field. I get dates like this from the source: 0 => "2023-10-27T00:00:00" 1 =&...
Oskar Calvo's user avatar
2 votes
1 answer
118 views

DrupalDateTime showing the date of the previous day and not the correct date while setting it

I have got the date from the url query parameter but while setting it to the default value of field_date form element it is showing the date of the previous day and not the correct date. use Drupal\...
Ali Rizvi's user avatar
0 votes
1 answer
109 views

Custom datetime field is treated as a string in Views when filtering

I have added a datetime field using BaseFieldDefinition::create() to my custom entity: BaseFieldDefinition::create('datetime') ->setLabel(t('Target date')) ->setCardinality(1) ...
Patrick Kenny's user avatar
0 votes
0 answers
259 views

Converting Unix Timestamp to Time Ago Format in twig

I'm working on a project where I need to convert a Unix timestamp to a "time ago" format (e.g., "2 hours ago," "3 days ago," etc.) using Twig. I've tried using the {{ ...
Shakil Ahmad's user avatar
1 vote
0 answers
25 views

How to output file upload date (of a file field) in a JSON-view?

I have rest_export view to generate json output of nodes. I'm trying to output a the upload date of files in a multivalue filefield, but can't find a solution. I tried to use the "rewrite results&...
Chris's user avatar
  • 11
0 votes
1 answer
91 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 ...
liquidcms's user avatar
  • 1,278
1 vote
0 answers
59 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 ...
Jipi's user avatar
  • 11
1 vote
1 answer
49 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 ...
elizoliva's user avatar
0 votes
1 answer
364 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\...
bruce_campbell_86's user avatar
3 votes
3 answers
2k 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 ...
Kevin's user avatar
  • 27.8k
1 vote
0 answers
90 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 -> ...
Asatur Vardanyan's user avatar
0 votes
1 answer
213 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 ...
loker's user avatar
  • 15
0 votes
1 answer
99 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('...
JAyenGreen's user avatar
1 vote
1 answer
2k 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 ...
Lasutriv's user avatar
0 votes
1 answer
1k 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 ...
user1252087's user avatar
1 vote
1 answer
82 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?
quantumized's user avatar
  • 1,217
2 votes
0 answers
75 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?
Eugene Kaganovich's user avatar
1 vote
0 answers
148 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 ...
Dancoo's user avatar
  • 11
-1 votes
1 answer
193 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: ...
Matoeil's user avatar
  • 3,429
3 votes
1 answer
110 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 ...
Scott's user avatar
  • 41
3 votes
0 answers
100 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 ...
Kevin's user avatar
  • 27.8k
0 votes
2 answers
534 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? ...
Georg Nordhausen's user avatar
1 vote
0 answers
147 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 ...
RominRonin's user avatar
-1 votes
1 answer
236 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 ...
Akshar Vijay's user avatar
1 vote
0 answers
70 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 ...
lolcode's user avatar
  • 884
1 vote
3 answers
5k 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 ...
4oh3's user avatar
  • 13
0 votes
1 answer
986 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 ...
Yuckle's user avatar
  • 116
1 vote
2 answers
2k 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, ...
Ahmad's user avatar
  • 2,835
1 vote
1 answer
109 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 ...
SkunkDog's user avatar
1 vote
1 answer
274 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 ...
Marshall Morrise's user avatar
2 votes
1 answer
533 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 ...
miststudent2011's user avatar
0 votes
0 answers
89 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 ...
Prudhvi's user avatar
  • 11
1 vote
0 answers
61 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 ...
Kevin's user avatar
  • 27.8k
0 votes
0 answers
71 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, (...
user3016811's user avatar
0 votes
2 answers
115 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 ...
Molesworth's user avatar
0 votes
0 answers
76 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, &...
MilanG's user avatar
  • 539
-2 votes
1 answer
52 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 ...
lol14's user avatar
  • 1
1 vote
2 answers
2k 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 ...
Diana's user avatar
  • 3,300
0 votes
1 answer
139 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 ...
hirani89's user avatar
1 vote
1 answer
940 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 ...
user13167's user avatar
1 vote
0 answers
246 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 ...
pandemoni's user avatar
3 votes
1 answer
886 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? ...
tawellman's user avatar
0 votes
1 answer
469 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 ...
Patrick Kenny's user avatar
0 votes
0 answers
200 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 ...
Pratip Ghosh's user avatar
1 vote
1 answer
271 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 ...
David Brugmans's user avatar

1
2 3 4 5
25