Skip to main content

Questions tagged [datetime]

DateTime objects provide information about a given date/time.

Filter by
Sorted by
Tagged with
1 vote
1 answer
26 views

Group matrix blocks by date

I'm trying to group events in a matrix field by day. Each date has a title and start and end time. I would like events for today, tomorrow and any dates beyond grouped separately. This is what I have ...
univers0's user avatar
0 votes
1 answer
33 views

Grouping and ordering entries by month

I need to be able to group dates by their month but then order them by month too because the order they're inserted into the database in na super field table isn't always in date order. So far, I have ...
Tyssen's user avatar
  • 653
2 votes
1 answer
86 views

Control Panel Date Picker: Inconsistent Date Format

In my plugin I have a datetime field defined in the settings template: {{ forms.dateTimeField({ label: "Ends at"|t('optimum'), instructions: experiment.isNew ? 'Defaults to 30 days ...
Matanya's user avatar
  • 472
1 vote
1 answer
23 views

Date of latest (parent) related entry?

I have a few sections whose main purpose is to be related to other entries - think authors' names, so a user can click through to all their entries. On the templates for these pages - as well as tag ...
Emma Swann's user avatar
2 votes
1 answer
123 views

Change Dates in Craft CMS

I want to change the dates of entries before the dates I actually edited the entries, I am trying to look in the database and I can't figure out which dates need to be changed. I have entries in Craft ...
user1837279's user avatar
1 vote
1 answer
30 views

Use date field to show related posts

I have a route setup for Dates and would like to show all entries from that particular Day and Month. For example, clicking 29/11/2022 would take you to mysite.com/dates/29-11 and I would like to see ...
supazu's user avatar
  • 526
0 votes
1 answer
69 views

Daylight Savings How?

How are you handling Daylight Savings Time with Solspace Calendar event elements? In our part of the world (America/Detroit), we seasonally offset our clocks by one hour, twice a year. Let's say we ...
Steve Mock's user avatar
0 votes
1 answer
40 views

LastInvalidLoginDate returning NULL, or current date if formatted

I'm wanting to show a user's last invalid login date within the control panel. No matter the value in the database, it comes back as NULL, unless I try formatting it as a date, then the current date ...
strandall's user avatar
  • 188
1 vote
1 answer
40 views

Sorting all matrix fields from multiple entries as one list

I have a section with a matrix field that collects multiple notes for each entry, each marked by the date the note is entered. Conceptually, the data is organized within the entries as: Entry A ...
Ed Hebert's user avatar
  • 145
1 vote
1 answer
45 views

Can't change author and dateCreated/postDate on duplicate entry action in Control Panel

We have a Craft-based email campaign builder that is up to date with Craft 3.7.x and plugins. I have a business logic plugin that works for a lot of custom functions but I can't seem to get this going....
Chad Crowell's user avatar
1 vote
1 answer
686 views

Checking for a valid date in a query string parameter using Twig

I have a form that lets you search articles by date. The 'Results' template uses dates from the query string in an Entries Query like this: {% set afterParam = craft.app.request.getQueryParam('after') ...
Karl Bishop's user avatar
1 vote
0 answers
29 views

Craft 2 - Date Comparison In Criteria - Impossible to access an attribute ("today") on a string variable (">=")

I am working with a template in Craft 2, and I am setting up the criteria for entries to be displayed. Here is my code (below). {% set today = now|date('Y-m-d') %} {% set criteria = { section: '...
buck1112's user avatar
  • 400
1 vote
1 answer
136 views

Query Entries only with postDate last of month

I'm trying to make a query for all entries on the latest of the month. So for example there is a list of entries that range from 01 January, 2020 to 31 October, 2021 each day has a separate entry. I ...
svanzon's user avatar
  • 11
1 vote
1 answer
122 views

Find entries with multiple start and end dates from the same date field

I've got a front end form where a user can select multiple months to find entries with dates in those months. I had code that does that for one month, but now I need to expand that to multiple months. ...
John's user avatar
  • 974
1 vote
1 answer
129 views

Commerce element query on custom field in console command

I'm on Craft 3.4.30 (latest 3.4) and Commerce 2.2.25 (latest 2.2): My product type "ticket" has a custom date field with handle productStartDate. E.g. the following query in TWIG works: {% ...
Matthias Redl-Mann's user avatar
1 vote
1 answer
460 views

Entries limited by date range

I'm trying to filter entries on the front end by a date range but no matter what I do I end up with no results, despite there being results in the, temporarily hard coded, date range I am using. {% ...
CreateSean's user avatar
  • 1,983
1 vote
1 answer
398 views

How to set the value of a Date field from PHP?

I'd like to set the value of a Date field from my custom PHP code. How can this be made? Which format does the Date field expect when using the setValue() function?
DaveFX's user avatar
  • 113
1 vote
2 answers
255 views

Convert string to date format that can be used in a craft.entries tag

I've got a date string from the url in this format: "2021-06-01" (year-month-day) and I want to find entries that have a date in the year and month from that string. The date is a date field ...
John's user avatar
  • 974
1 vote
1 answer
33 views

Dates for entries are in different language

When the user wants to edit the Post Date or Expiry Date of an entry (channel/structure), the calendar is in Welsh language. I have no clue how this happened. How can I change this? Thank you
Paloma Martinez's user avatar
1 vote
2 answers
475 views

Displaying updated date for entry

I want to display the date an entry has been updated if it is later than the post date. So I've tried this: {% if entry.dateUpdated >= entry.post %} Updated on {{ entry.dateUpdated.format('...
Andrew's user avatar
  • 748
1 vote
1 answer
9k views

GraphQL query entries by DateTime field between two dates

I am trying to query entries in GraphQL by custom DateTime field value. It works with the base String value like ">=2020-10-01", However querying between two dates like "['and', '>...
Alex89's user avatar
  • 183
1 vote
2 answers
265 views

How can I change the Date Created for Assets?

I'm using graphql to pull in some assets/pdfs and ordering them by dateCreated, however the files go back a few years (i.e. files from 2019, files from 2018 etc.) but they weren't uploaded in the ...
Grant's user avatar
  • 11
1 vote
1 answer
320 views

How can I merge a Modified Date and Time in Twig?

I am trying to generate a modified date and time from a combination of content fields and the current date but I am getting stuck and keep hitting errors, so my logic is either not correct or I am ...
Terry Upton's user avatar
  • 1,894
1 vote
1 answer
546 views

How to filter entries with null value in date field?

I have date field in entry that is empty therefore has null value. I'd like to filter entries that have date field value equal to null. How would I set that parameter on element criteria object? I don'...
Dominik Krulak's user avatar
2 votes
0 answers
174 views

How to search/filter in CP by date range?

Is there a way in the control panel to list all entries with a date field between two dates? For example, last updated between 12/16/2019 and 2/15/2020. Interested in doing this for both automatic ...
Josh Coady's user avatar
0 votes
1 answer
159 views

How get entries between mutiple dates, ordered by date?

I'll import (event) entries with feedme in craftcms 2 from an API who I'll can't change. The api gives the startdate off the events in a dateTime object. The allDay events have a date without time. ...
Maarten Heideman's user avatar
0 votes
0 answers
135 views

How to automatically set time in a date/time field?

For a specific kind of entry I need the time in a date/time field to either automatically display as 23:00/11pm on the user dashboard, or, permanently set the time on that date/time field to 23:00/...
JJefferyDev's user avatar
1 vote
1 answer
72 views

How to use createFromString() in Craft 3

In Craft 2 I've used createFromString() as following: DateTime::createFromString($pubDate, craft()->timezone) But if I use this function in craft cms 3 then I'm getting the following error: Call ...
johirpro's user avatar
  • 185
0 votes
0 answers
139 views

Date Field Validation by PHP plugin

I have a form for updating user info, with a field of birth date. However, I am struggling to develop a validation for this date field by PHP. Its frontend code is this; {% set tz = craft.app....
Kota.M's user avatar
  • 423
1 vote
1 answer
222 views

Order matrix blocks by date field

I'm using a matrix inside a Super Table to organize events, and I'd like to order the events using the date field for each event. I'm currently showing the first five events using limit then using ...
univers_'s user avatar
  • 185
2 votes
1 answer
335 views

Allow user to set timezone from within Craft when entering a time in a date/time field

We are creating a small site to manage meetings that take place in many timezones. Administrators of the site will create meetings on behalf of teams everywhere. They may be in pacific timezone and ...
kenyabob's user avatar
  • 121
1 vote
1 answer
101 views

Grouping entries by a custom date conditional

I'm looking to group entries based on a condition between two custom date fields and the current date. I'm not even sure this is possible, but this is how it would appear visually: Happening Now ...
John Johnson's user avatar
1 vote
1 answer
227 views

Empty Date Field

I currently have an empty date field, it's unset in the field. I know from reading this becomes "Today's Date" but for some reason the following code is just not working when testing for empty? Unsure ...
JMKelley's user avatar
  • 1,416
1 vote
2 answers
115 views

How to change the day of the week?

Good day! I display the day of the week on the site {{ now|date("l") }} How to change for example Monday to Mondays (on Mondays)? Thanks in advance :)
paveell's user avatar
  • 31
1 vote
1 answer
172 views

Craft CMS 3 Date Field problem

I added some date fields on my entry. I select a date and save the entry. But the date field saved the day before. Every editing the entry continue saving the day before. When the date comes to the ...
Coskun's user avatar
  • 11
2 votes
1 answer
135 views

How to get users with birthday today in plugin/module?

How does one retrieve users from Craft3 DB whose birthday is today? Birthdate field type is Date/Time. Have a working PHP/MySQL example, but unsure how to port this to Craft3 syntax. $sql = '...
PixelGarden's user avatar
3 votes
2 answers
1k views

Query entries by custom date field (for a particular year)

So I'm trying to get all entries that have a particular year assigned to a custom date field. (Could be any day/month in that year). The custom field is startDate and my attempt at a query - which ...
James Greig's user avatar
1 vote
1 answer
79 views

Find Entries based on Field Values

I have a set of events I want to query based on user-input date times. How do I achieve something like this? {% set entries = craft.entries.section('events').minScheduleDate('>=', 'now')....
Davina Leong's user avatar
1 vote
1 answer
123 views

Can I query based on a date field rather than the postdate?

I'm passing along a year as the yearQuery variable. Later in my template, I am doing this: {% set eventEntries = craft.entries .section('events') .eventStartDate('>=' ~ yearQuery) ....
gjhead's user avatar
  • 123
1 vote
1 answer
22 views

Displaying a month name in an archive

I'm trying to figure out how I can print the month name i.e April in the below. Currently, it's printing the last three months that contain entries. {% set year = craft.request.segment(4) %} {% set ...
sarah3585's user avatar
  • 899
1 vote
1 answer
446 views

How to edit a date field in a plugin

So I want to edit date type filed on entry save, but I don't know how to format it. It times out on string and don't seem to accept DateTime objects either. Event::on( Elements::class, ...
Lukigi's user avatar
  • 565
1 vote
1 answer
104 views

Can I use a Global Variable for date/time?

The goal is to create a global variable that allows the user to specify how they would like to format the date/time for entries. I'd like to remove the hardcoded format shown here: {{ entry.postDate|...
Vaughn D. Taylor's user avatar
1 vote
1 answer
467 views

How to get all entries posted within a specific year?

I am trying to get all entries posted from 2018 and only 2018. All the other methods I've seen are for from a specific date or between two dates. Is there a simple way to get all posts from 2018 ...
Jay's user avatar
  • 1,042
2 votes
2 answers
958 views

Get entries after a certain time

I am trying to get all entries from my events section in Craft 3 that occur after 17:00. My current code is: {% set events = craft.entries.section('events').eventStartTime('>= ' ~ '17:00'|time )....
jaypratt's user avatar
  • 113
1 vote
1 answer
84 views

Date range to include end date

I am grabbing a date range from a URL query string like so: https://website.com/qa/search-feedback-results?datestart=2019-01-01&dateend=2019-02-26 I can't figure out how to include posts that ...
Lori's user avatar
  • 866
1 vote
1 answer
39 views

How I can sort my entry that belong to 3 section on date?

{% set blog = craft.entries.section('blog').all() %} {% set news = craft.entries.section('news').all() %} {% set caseStudies = craft.entries.section('caseStudies').all() %} {% set allEntries = blog|...
Людмила Петчик's user avatar
2 votes
1 answer
1k views

Order entries by custom date and time fields

I have an events channel where each entry has three custom date/time fields: startDate (Date Only) startTime (Time Only) endTime (Time Only) I was originally using this code to set my entries, but ...
artmem's user avatar
  • 1,022
1 vote
1 answer
56 views

Archive page date logic stopped working

Edit: This is confirmed as a bug in Craft, that will be fixed in its next release. If you're running into this, please see the temporary fix over at GitHub: https://github.com/craftcms/cms/issues/3772 ...
Ernie Smith's user avatar
1 vote
1 answer
108 views

Event archives with custom date field

I'm trying to set up a past events archive. Followed the guide provided by PT: craft cms guide to set up an archive. The only difference is that I use a custom date field (dateAndTime) and not ...
jjem's user avatar
  • 497
1 vote
1 answer
44 views

Current day display on day later

in the CP settings, timezone is set to UTC +1 Europe/Zurich when I try this code: {% set currDay = now|date() %} {{ currDay|date('l d F Y') }} it outputs "Mercredi, 16 janvier 2019", but we're ...
jjem's user avatar
  • 497

1
2 3 4 5