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.
1,218
questions
-3
votes
0
answers
30
views
How to update/convert stored field value in webform database from am to pm in Drupal 10
I have a field in database with datatype as integer, in my custom module I had to convert the date to readable format in d/m/y, the value is inserted to a custom table field using strtotime(date('d/m/...
0
votes
2
answers
57
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 ...
0
votes
0
answers
14
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 =&...
2
votes
1
answer
95
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\...
0
votes
1
answer
51
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)
...
0
votes
0
answers
176
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 {{ ...
1
vote
0
answers
21
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&...
0
votes
1
answer
66
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
vote
0
answers
54
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 ...
1
vote
1
answer
46
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
37
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
259
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\...
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 ...
1
vote
0
answers
81
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
201
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 ...
0
votes
1
answer
63
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('...
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 ...
0
votes
1
answer
957
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
71
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?
2
votes
0
answers
63
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
129
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 ...
-1
votes
1
answer
127
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: ...
2
votes
1
answer
103
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 ...
3
votes
0
answers
89
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 ...
0
votes
1
answer
450
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
117
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
181
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
37
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 ...
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 ...
0
votes
1
answer
886
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 ...
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, ...
1
vote
1
answer
70
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
235
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
480
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
87
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 ...
1
vote
0
answers
58
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 ...
0
votes
0
answers
68
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
110
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
70
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, &...
-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
vote
2
answers
1k
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 ...
0
votes
1
answer
91
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
859
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
199
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
846
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
416
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
191
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
235
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
889
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 ...
1
vote
1
answer
248
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('', '', '', '', '', '', ...