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
3 votes
3 answers
137 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 ...
user avatar
  • 26.5k
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 ...
user avatar
  • 51
1 vote
0 answers
16 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 -> ...
user avatar
0 votes
1 answer
35 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 ...
user avatar
  • 15
0 votes
1 answer
13 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('...
user avatar
0 votes
0 answers
11 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 ...
user avatar
  • 1,234
0 votes
0 answers
36 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 ...
user avatar
  • 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-...
user avatar
  • 1
1 vote
1 answer
224 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 ...
user avatar
0 votes
0 answers
22 views

Set data value of created date with Rules

I need to set the created date of all nodes of a content type X to 'now' if the created date is older than 14days. It should be happening when running cron. Cant get it running with Data Comparison ...
user avatar
0 votes
0 answers
36 views

How to access data in Twig in module extended template

I'm new at developing Drupal. I'm using Drupal 8 and I want to display datetime fields in a special way. Here is how my module_name.module and template file looks like: function module_name_theme($...
user avatar
  • 1
1 vote
1 answer
126 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 ...
user avatar
1 vote
1 answer
21 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?
user avatar
2 votes
0 answers
25 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?
user avatar
1 vote
0 answers
42 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 ...
user avatar
  • 11
-1 votes
1 answer
42 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: ...
user avatar
  • 2,775
1 vote
1 answer
27 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 ...
user avatar
  • 11
2 votes
0 answers
51 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 ...
user avatar
  • 26.5k
0 votes
1 answer
74 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? ...
user avatar
0 votes
0 answers
22 views

Change booking end-date in iCal Feeds import

I have an D9 site for a villa that can be rented. To show availability, I import the iCal calendar of bookings from a booking site, using the Feeds and Feeds iCal modules (the last one I updated the ....
user avatar
  • 47
1 vote
0 answers
28 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 ...
user avatar
-1 votes
1 answer
58 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 ...
user avatar
0 votes
0 answers
9 views

Rewriting Start and End Dates in Views where Date is stored in single field

using Drupal 7, I have the Profile2 module installed. Within that, I have a field called "Employment Dates" and a user can enter a start and end date on this field. They can also leave the ...
user avatar
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 ...
user avatar
  • 844
1 vote
1 answer
1k 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 ...
user avatar
  • 13
0 votes
1 answer
193 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 ...
user avatar
  • 66
0 votes
2 answers
638 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, ...
user avatar
  • 2,697
1 vote
1 answer
18 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 ...
user avatar
1 vote
1 answer
102 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 ...
user avatar
1 vote
1 answer
222 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 ...
user avatar
0 votes
0 answers
73 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 ...
user avatar
  • 11
1 vote
0 answers
53 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 ...
user avatar
  • 26.5k
0 votes
0 answers
46 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, (...
user avatar
0 votes
2 answers
73 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 ...
user avatar
0 votes
0 answers
58 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, &...
user avatar
  • 375
-2 votes
1 answer
49 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 ...
user avatar
  • 1
1 vote
2 answers
383 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 ...
user avatar
  • 1
0 votes
1 answer
40 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 ...
user avatar
1 vote
1 answer
328 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 US format "m/d/Y" for all date fields that the user entered on the form (but not for system ...
user avatar
1 vote
0 answers
76 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 ...
user avatar
3 votes
1 answer
584 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? ...
user avatar
0 votes
1 answer
124 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 ...
user avatar
0 votes
0 answers
142 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 ...
user avatar
1 vote
1 answer
94 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 ...
user avatar
0 votes
0 answers
434 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 ...
user avatar
  • 375
1 vote
1 answer
145 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('', '', '', '', '', '', ...
user avatar
0 votes
1 answer
60 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) { $...
user avatar
0 votes
0 answers
31 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 ...
user avatar
  • 1
1 vote
1 answer
426 views

How can I programmatically set date field Month, Day, Year dropdowns in Paragraphs?

I'm setting a basic date field (and several other text fields) programmatically when creating a paragraph. The database is showing that it is getting my date, which is being stored inY-m-d\TH:i:s ...
user avatar
1 vote
1 answer
490 views

Change exposed filter date format with Search API

We are using Search API for a customer website and we have a View with a start and end date exposed filter. The view only filters correctly if we use the m/d/Y format, which is not valid in Brazil, ...
user avatar
  • 13

1
2 3 4 5
25