11 votes
Accepted

Display entries if Field Date is past Now

You can combine a for and if statement in twig, so you don't necessarily need to use search. Something like this might get you a bit closer: {% for entry in craft.entries.section('event') if entry....
Steve Holland's user avatar
9 votes

How do I set up event listing & detail pages with entry post dates that are in the future?

A better/easier route would be to just create custom Date/Time fields that store the event start and end dates. Entries’ Post and Expiry dates are meant to define when the entry should be visible on ...
Brandon Kelly's user avatar
6 votes
Accepted

How can I group entries based on a dateTime field?

You're currently grouping on the myDate field, which essentially creates a new array index for each date (e.g. 2016-01-01) which is why you're getting your current output. To group by year, this ...
Mats Mikkel Rummelhoff's user avatar
6 votes
Accepted

Date/Time field outputting time with additional minutes

You are using the wrong variables. The 10 is there because it means October not 10 minutes. You have to use | date("g:ia”).
KSPR's user avatar
  • 3,776
6 votes
Accepted

Query entries between two values

I got the answer to this thanks to @BrandonKelly from a comment in this question: How can you return elements between two values? Turning it into a subarray does the trick: expirationDate: [ 'and', '&...
Steven Thate's user avatar
5 votes

Error when submitting Date Field from the front-end: cannot be blank

The input tag presented in the comments above does not appear to use the correct input tag format for the date field. To submit a date field on the front-end, your input fields need to be setup with ...
Ben Parizek's user avatar
  • 13.4k
5 votes
Accepted

date_modify relative time

You could use the diff method to get the number of days between two dates. So for example: {{ date(entry.dateCreated|date('c')).diff(now).days }} days ago In my example between today (using now) and ...
Steve Holland's user avatar
5 votes
Accepted

How can I set the postDate and expiryDate from a front-end date picker via plugin?

I believe I have figured it out, please correct me so I can update the answer if I am too far off. TL;DR: I am using a date picker (no time) on a front-end form. The user chooses a date and it ...
Damon's user avatar
  • 4,706
5 votes
Accepted

Escape characters in format

After trial and error I figured out you can escape characters using double backslash. {{ article.postDate.format('j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> F Y') | raw }} Outputs: 14<sup&...
William Isted's user avatar
5 votes

First and Last day of Week + Month in Twig

The version below could be more understandable in some cases. First day of week (assuming Monday is the first day): {{ now | date_modify('monday this week') | date('m-d-Y') }} or alternatively: {{ ...
Romain P.'s user avatar
  • 1,808
5 votes
Accepted

List Only Available Times/Dates in Solspace Calendar

Edited to provide a cleaner solution: This code will display different contents for available times and unavailable times in 30 min increments, and makes no assumption on how long your events are. {%...
Solspace's user avatar
  • 1,410
5 votes
Accepted

Date fields saving the wrong date from front-end form

You need to include a timezone parameter to your form in order to get the correct one. <input type="hidden" name="postDate[timezone]" value="America/Los_Angeles"> If you don't include ...
Robin Schambach's user avatar
5 votes
Accepted

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

I think your problem is you're converting the date to a year string then converting that to an atom value. Just convert the date straight to an atom value: {% set yearStart = "#{year}-01-01"|atom %} {...
kmgdev's user avatar
  • 1,169
4 votes

How do I set up event listing & detail pages with entry post dates that are in the future?

As Brandon wrote, I just created a date field {{eventDate}} and then just search based on if the eventDate was later than NOW in the section named Events. {% set events = craft.entries.find({section:'...
Paul Frost's user avatar
  • 1,060
4 votes
Accepted

If date is between conditional

This conditional should work: {# Saison Trigger #} {% set saison = now|date('m-d') %} {# Check for each Season #} {% if saison > '11-22' or saison <= '03-21' %} {% set currentSaison = '...
carlcs's user avatar
  • 36.2k
4 votes
Accepted

Group by day does strange exeptions

When you specifically group on dateField.day (in your case, the |group('datum.day') part), the group filter won't care about the month or year for the date field – only the day. This means that any ...
Mats Mikkel Rummelhoff's user avatar
4 votes

Display X minute / hours / days in entries

Check out the DateTimeHelper method timeAgoInWords. It will do what you are after. https://craftcms.com/classreference/helpers/DateTimeHelper#timeAgoInWords-detail There is even a handy twig filter ...
Fyrebase's user avatar
  • 735
4 votes
Accepted

date in database -1 day as on frond-end

The database will be storing the date as seconds since 1970 (epoch) and your view on that is not localised. However, the front end date is localised for your time zone. Of this I am more sure than ...
Jeremy Daalder's user avatar
4 votes

Date value different in CP and database

Craft stores all dates in UTC to the database, no matter what timezone you configure in settings. When (user) models are populated, e.g. for use in the CP, DateTime objects are created from these ...
carlcs's user avatar
  • 36.2k
4 votes
Accepted

Display Full Month Name

Try using this. {{ now|date("F, Y") }} You can find the format strings for the date filter: http://php.net/manual/en/function.date.php
a-am's user avatar
  • 2,857
4 votes
Accepted

How to get entries between a time

Entry::find()->startDate('>='. $someTime).endTime('<='.$someOtherTime).all(); Those variables can be timestamps, DateTimes or a correctly formated time string. Here are some variants of ...
Robin Schambach's user avatar
4 votes

Entry Post Date Format time since - X days ago

It looks as though Craft 3’s built-in duration Twig filter might help: Posted {{ entry.myDateField.diff(now) | duration }} ago. With a bit of additional logic, you can make this more useful, after ...
August Miller's user avatar
4 votes

Change Dates in Craft CMS

You can change the postDate of any entry manually through the entry edit form. Click on the Post Date input field in the sidebar to the right, there you can set the post date to whatever date and time ...
MoritzLost's user avatar
  • 11.1k
3 votes

date_modify relative time

I have a plugin that adds the time_diff Twig filter to Craft: https://github.com/mildlygeeky/craft-timediff There is one possible issue (in either PHP or Craft) around DST, and I will add that to ...
Patrick Harrington's user avatar
3 votes
Accepted

Displaying entires by year from a custom date field

Looks like I finally found an answer to it year being my param date being my custom date field {% set dateParam = 'and, >= ' ~ year ~ '-01-01, < ' ~ (year + 1) ~ '-01-01' %} <ul> {% ...
Eric Chantigny's user avatar
3 votes

Escape characters in format

Try the Twig date filter instead: {{ article.postDate|date('jS F Y') }} to wrap the ordinal in <sup>: {{ article.postDate|date('j') }}<sup>{{ article.postDate|date('S') }}</sup> {{...
carlcs's user avatar
  • 36.2k
3 votes

Showing pagination for a date range of entries

It's difficult to give specific code help without seeing some input/output examples, but here's a go-by: You can say that an event occurs during a date range if: The event begins before the date ...
Michael Rog's user avatar
  • 3,410
3 votes

Show events until Midnight

Have you tried?: {% set upcoming = craft.entries.section('gigEntry').status('pending', 'live').gigDate('>= ' ~midnight) %}
erwinheiser's user avatar
3 votes
Accepted

How to edit the Date Created value that appears on the Entry page

If you want to edit that value in the database, then you'll need to find the corresponding row in the craft_elements table and update the dateCreated column there.
Brad Bell's user avatar
  • 67.4k
3 votes

Display entries if Field Date is past Now

Craft has changed since the above answer was given. The now object must be a part of the string, rather than concatenated as an object. so instead of: {% set futureEntries = craft.entries.section('...
ToddPadwick's user avatar

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