Questions tagged [datetime]

DateTime objects provide information about a given date/time.

Filter by
Sorted by
Tagged with
0
votes
0answers
14 views

Filter Super Table Rows by Date Field

I have a Super Table field called locationPricing with a date field inside it called expiration. I want to only display the Super Table rows where the expiration date has passed. Here's what I've ...
0
votes
0answers
23 views

Craft cms 3 Date Field problem

i added some date field on my entry. I select a date and save entry. But the date field saved the day before. Every editing the entry continue saving the day before. when date comes to the 27 ...
2
votes
1answer
27 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 = '...
2
votes
2answers
54 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 ...
0
votes
0answers
9 views

Craft Guest Form Category, Date Not Saving

The examples are not working for me. The category value via the Guest Form plugin is not saving: <select name="fields[adCategory][]" id="adCategory"> <option value="">-- Category --&...
1
vote
1answer
32 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')....
1
vote
1answer
27 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) ....
1
vote
1answer
12 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 ...
1
vote
1answer
63 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, ...
1
vote
1answer
20 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|...
1
vote
1answer
57 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 ...
1
vote
2answers
68 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 )....
1
vote
1answer
34 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 ...
1
vote
1answer
27 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|...
1
vote
1answer
205 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 ...
1
vote
1answer
36 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 ...
1
vote
1answer
63 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 ...
1
vote
1answer
32 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 ...
1
vote
1answer
57 views

Date Limit on Element Query

I have a custom date field - "renewalDate" - which I want to use to limit an entry query. Here is the code: When I run that it throws this error: "Calling unknown method: craft\behaviors\...
1
vote
1answer
74 views

Multi-Language Site but the Date should be always in English

with {{ block.timeLimit|date('M d Y H:i')}} i can get the real Date & Time in always the real Language from the Site. If the Page is German output is Dez, in English output is Dec. How can i set ...
2
votes
0answers
150 views

Order entries by custom date field

I want to modify this query so that the dated entries are sorted in descending order on a custom field called 'startDate'. Have tried adding .order('startDate') to the end of the craft.entries(query)....
3
votes
2answers
301 views

Entry Post Date Format time since - X days ago

Is there anyway to get my date formats looking like Facebook? I'd like to get my articles to have this as a date format: "5 min ago", "yesterday", "3 days ago", "4 months ago" and then once it reaches ...
1
vote
0answers
37 views

Archiving by month and year - timezone could not be found error

Following the answer in this thread -Linking and showing archive by month by P&T has worked fine for previous sites but now I'm getting the following error. I've checked I have a Time zone ...
1
vote
1answer
33 views

Pagination with if statement date modify

How can I incorporate the date_modify into the craft.entries query so that the pagination takes into account this criteria? At the moment the limit is also accounting for past entries and I'm hitting ...
0
votes
2answers
91 views

Does Craft save dates in the locale format?

I have a website with multiple locales (English, Dutch, French, German and Spanish). I'm saving dates on a front-end form through Ajax, but it seems that Craft saves the dates in the locales' format, ...
1
vote
2answers
38 views

Caching question

How does the Craft CMS cache work? I want to show a certain message if the server date is between x and y. Can I do this by using an Twig if/else statement or is this cached? My code is like this: {...
1
vote
1answer
89 views

Displaying entries from a specific custom date year

I've a list of entries, all with custom dates. Is there a way to show entries from a specific year, just using the custom date rather than the posted date? Any help is much appreciated!
1
vote
1answer
78 views

How do multiple date queries differ between Craft 2 and 3

After spending a lot of time solving this for myself I thought I'd share it. In my Craft 2 template I had this query: {% set result = craft.entries({ section: 'events', eventDate: ['and', '&...
1
vote
1answer
48 views

Include Time In PostDate/DateTime Field Control Panel Display

In Craft 3 if you use a DateTime field and have it set to time only, it still displays as a date in the Control Panel with no time. Even if it is used as a date and time field, just like entry post ...
2
votes
1answer
163 views

Comparing date field object with global variable “now” gives unexpected result

The goal is to show a word when date field qualifies for tomorrow or today instead of numeric date. Setting and calling variables: {% set deliveryDate = order.deliveryDate %} {% set tomorrow = now|...
2
votes
1answer
328 views

Date fields saving the wrong date from front-end form

I have a front-end form with two date fields. After upgrading to Craft 3 and implementing what I believe to be all the changes concerning front-end forms in Craft 3 I am experiencing some odd behavior....
0
votes
1answer
588 views

Craft 3: Error “variable now does not exist”

I upgraded a Craft 2 project to Craft 3 and am working on updating some template quirks. One I am having trouble with involves the following element query: {% set scriptsAboutToExpire = craft.entries(...
4
votes
1answer
360 views

How to get entries between a time

I'm using Craft 3 and I would like to do the following thing: There is a start date and an end date filed in entry, is it possible to get entries that are between these two dates in PHP? Thank you!
1
vote
1answer
62 views

Grouping by Date (Day) Not Working Correctly

For a week-long schedule, I'm trying to group events that occur on the same day, and also fall into one of two classifications— they are free if a pass is purchased or not included in the pass. {% ...
1
vote
1answer
316 views

Display Full Month Name

Currently trying to get the date filter to display 'April' instead of concatenated version 'Apr'. My code below is: {{ now|date("M, Y") }}
1
vote
2answers
295 views

Sort entries by time part only of DateTime object

I am trying to filter and sort show entries by what time they begin display the current show I have two fields, startTimeand endTime, and while Craft lets me display only the time part in the ...
1
vote
2answers
200 views

Sprout Form Date/Time field not displaying

I'm working on an inherited site where I have a sprout form and am adding additional fields. I have added a date/time field to the form with the settings in this screenshot. In my template where all ...
1
vote
1answer
598 views

Date filtering returning wrong results - timezone issue?

I'm running into an issue where incorrect results are being returned when filtering Craft Commerce orders by date in a template. Can anyone help? I cannot figure out what is going on. FACTS: Craft ...
0
votes
0answers
101 views

Updating `{{ forms.dateField }}` value from GET variable

I want to use the built-in Craft field macros to show a date field in a plugin template for filtering. I can retrieve the submitted value on any submission (via GET) but how do I then prepopulate ...
1
vote
1answer
659 views

Query entries between two values

I am trying to query entries (scripts) when a custom expiration date field is within a certain range. These questions/answers helped me get as far as I am, but I'm still stuck: Advanced query/filter ...
2
votes
1answer
161 views

query orders by date AND time in craft commerce

How can I query all completed orders within the last hour? It seems craft is only comparing a date by YYYY-MM-DD. Following query collects all orders from the same day, as {{dateFrom}} would output ...
1
vote
1answer
2k views

DateTime::__construct(): Failed to parse time string

I want to get the lates postDate of a List and format it for the cache tag {% set latestSubmission = craft.amForms.submissions( { formHandle: 'reservation', order: 'dateCreated desc' }).datum('&...
1
vote
1answer
30 views

MySQL ColumnType::Time does does not populate model from setAttribute()

I have a record with a time field set like this: 'startTime' => array(AttributeType::DateTime, 'column'=>ColumnType::Time, 'required' => true), 'endTime' => array(...
3
votes
1answer
252 views

Pull DateTime field using alternate timezone?

I have a question regarding populating models, in that I have a DateTime field in my model that I'm pulling / populating from the database. The DateTime value does not include the timezone it was set ...
1
vote
1answer
51 views

Calendar archives architecture

I created a section on a site that shows a two-month calendar. The calendar has links to entries based on a release date. The release dates are created using a date/time filed. (Dates are different ...
1
vote
1answer
59 views

How do I get the number of days in the previous month?

I am working on a calendar, and so far I know how to get the number of days in the current month. {% set daysInMonth = time|date('t') %} But how can I get the number of days in the previous month? ...
2
votes
0answers
72 views

Timezone drama for events calendar

Working on site where there is events calendar of conferences and webinars. Users are (literally) all over the world. Trying to figure out how I am going to handle time zones. Factors: - Fields I am ...
1
vote
1answer
69 views

Sorting by date field across sections not working

I've seen a number of answers prescribing how to sort across different sections...but I'm not seeing it work. Here's what I've tried: {% set profileIds = craft.entries.section('profiles').order('...
1
vote
1answer
137 views

Query multiple fields with dates

So I'm trying to build a query based on events and their start and end dates. Once a user selects a year, I want to display all events that took place in that year, but also display events that might ...
2
votes
1answer
184 views

How do I query for orders that were completed between two dates?

I am attempting to get orders that were completed between two dates and the "before" and "after" criteria parameters don't seem to work. Perhaps I am using the wrong syntax? Example of how I am using ...