Skip to main content
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,786
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
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

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,852
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,199
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

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.3k
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
Accepted

Daylight Savings How?

If I'm understanding correctly, the three dates should all appear as the same time on the frontend, as if there was no regional time change? You can do this by using Calendars .format() method on ...
andrewmenich'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.5k
3 votes
Accepted

Is it possible to use set the locale manually in a template?

Completely, 100% untested, but I think you'd be able to pull it off with a pretty simple plugin that added a new Twig filter (check the Twig Extensions switch). From a template you'd something like: ...
Brad Bell's user avatar
  • 67.5k
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
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.5k
3 votes

Get future multi-day event entries with custom date field

I think the simplest solution would be to make the eventEndDate field required even for single day events. Then you could do something like this: {% for event in craft.entries({ section:'events', ...
Alex Roper's user avatar
  • 2,642
3 votes
Accepted

Check if we're the second or last sunday of the month today

Maybe it doesn't work because the monthyear variable is formed in dutch and not english? Yes that's part of the problem. Have a look at PHP's relative formats page to see what it supports. You can ...
RitterKnight's user avatar
  • 6,582
3 votes
Accepted

Pull DateTime field using alternate timezone?

100% untested, but something like this should work: Have your model override BaseModel's populateModel. Find the DateTime field you're interested in and get its value. Create a new DateTime object ...
Brad Bell's user avatar
  • 67.5k
3 votes

Craft 3: Error "variable now does not exist"

You need to convert the DateTime object via Filter: now|date('U') or via function now.format('U') This will format the date as a UNIX timestamp which is sufficient for querying. MySQL datetime ...
Robin Schambach's user avatar
3 votes

How do multiple date queries differ between Craft 2 and 3

My Craft 3 version is: {% set result = craft.entries() .section('events') .eventDate( ['and', '<' ~ now|atom, '>' ~ now|date_modify('-6 days')|atom ] ) .results(':notempty:') ....
Paul Frost's user avatar
  • 1,060
3 votes
Accepted

Entry Post Date Format time since - X days ago

Chiming in with a solution made from reading the above solution and comments. I also wrapped it in a macro. {% macro timeAgo(entry) %} {% set dateOneHourAgo = now.modify('- 1 hour') %} {% ...
Amos Whitewolf's user avatar
3 votes

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

I made a plugin to do this. https://github.com/IndigoViking/Translitedated Use it just like the |date filter (new filter is |dated) and pass it the date format and the locale you would like to use. ...
Chattervast's user avatar
3 votes
Accepted

Order entries by custom date and time fields

You'll want to change that startTime to field_startTime. Anything in the orderBy gets passed directly onto SQL and Craft is smart enough to do the replacement for startDate behind the scenes, but ...
Brad Bell's user avatar
  • 67.5k

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