2

The special strings :empty: and :notempty: might be what you're looking for. The docs list it only against expiryDate, but I think it's available for any field: https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#expirydate


2

After trying multiple options found an answer:


2

String interpolation in Twig only works with double-quoted strings. Change the .startDate line to .startDate(['and', ">= #{start}", "< #{end}"]) and it should work.


2

Here's an example value that will set it to today: [ 'timezone' => 'America/New_York', 'date' => date('m/d/Y') ] As always, easiest to find out how it's done by inspecting the fields as they are saved in the control panel.


2

You could do this: {# Your date 2020-11 in atom format e.g 2020-11-01T00:00:00+01:00 #} {% set departureDate = craft.app.request.getParam('departure') | date("Y-m") | atom %} {# Your date + 1 month in atom format e.g 2020-12-01T00:00:00+01:00 #} {% set untilDate = departureDate | date_modify('+1 month') | atom %} {# Query between those 2 dates #} ...


2

Date fields in Craft are returned as DateTime objects, so you need to convert these to a string to be able to compare them. The best way of doing this is to use the yyyy-mm-dd format as this makes it is easy to compare dates. So your comparison would become: {% if (entry.dateUpdated|date('Y-m-d')) >= (entry.postDate|date('Y-m-d')) %} Updated on {{...


2

What an idiot. I almost never use Advanced element queries which is why it never popped into my head I guess. So you can add where() and orWhere() into your standard craft.entries calls. So my code becomes {% if craft.app.request.getParam('departure') | length %} {% for dept in craft.app.request.getParam('departure') %} {% set lastDay = dept [0:7]...


1

Found it: the reason for the Exception is, that the dynamic method productStartDate (coming from the CustomFieldBehavior) needs an Array as parameter. I have no clue why I get this misleading Exception though... So finally, this works: use craft\commerce\elements\Product; $product = Product::find() ->type('ticket') ->...


1

You're not checking against a valid field there - try using entry.postDate instead of entry.post


1

You should be able to use the date string you get from your parametern without even editing it. {% set entries = entries.startsOn(craft.app.request.getParam('departure')) %} More information about querying on datefields can be found here: Date Fields | Craft CMS Documentation | 3.x


1

If you go to that user's account settings, then click on the "Preferences" tab, I'm guessing they have their "Formatting Locale" setting set to Cymraeg.


1

Having done some further testing and research I believe this is a case of having to merge two date objects and ensuring that these are set as date/time objects when merging them into a variable. Here are some examples way: {% set thisWeeksDayAndTime = thisWeeksDay|date() ~ ' ' ~ classStartTime|time() %} {% set thisWeeksDay = page.startDate|date_modify('...


1

Perhaps you could use the Preparse Field plugin, so that you only need to deal with one field. That would make the query easier. https://plugins.craftcms.com/preparse-field


1

I solved that by adding a dropdown field to user profiles where I allowed users to select timezone and then in custom module set the selected timezone like this: class SiteModule extends Module { public function __construct($id, $parent = null, array $config = []) { // Set correct Timezone $currentUser = Craft::$app->getUser(); ...


Only top voted, non community-wiki answers of a minimum length are eligible