Questions tagged [datetime]

DateTime objects provide information about a given date/time.

Filter by
Sorted by
Tagged with
3
votes
1answer
746 views

Get entries by date but ignore time

I'm trying to pull entries from a database where the postDate is a specific date. {% set today = thisyear ~ "-" ~ thismonth ~ "-" ~ day %} {% set today = today|date('Y-m-d') %} {% set entries = ...
11
votes
2answers
1k views

Search matrix for blocks with upcoming dates

I have a matrix field with one "event" block type that contains several fields. One of those fields is a date field. Is there a way to get just blocks with upcoming dates?
4
votes
2answers
7k views

Is it possible to output month names in my native language?

I'm doing this: {# Get events from `events` section in desired sort order #} {% set allEvents = craft.entries.section('events').order('eventsDate asc') %} {# Loop through `allEvents` and print the ...
6
votes
2answers
1k views

How do I save a Plugin's date settings-field?

I've got a plugin with some custom settings, like this: protected function defineSettings() { return array( 'serviceendpoint' => array(AttributeType::String, 'required'=>...
3
votes
3answers
2k views

How to display entries with a custom date field within month

I've got a date field, and I'm grabbing the month and year from the url. What I'm after is to display all the events within the month, but for some reason I can't get this to work {% set ...
3
votes
2answers
2k views

How to show entries which are live between dates regardless of postdate or expiry dates?

I'm trying to show live entries to user by selecting list of months in a dropdown. Some my entries are live for 2 or 3 months. I having trouble in finding right method. I have tried using after and ...
11
votes
3answers
2k views

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

I'm struggling to set up a listing template and a detail template which will display "event" entries with post date set in the future. I keep getting a 404 error on the detail page. How do I set up ...
8
votes
3answers
9k views

How to calculate the number of days left?

I want to calculate the remaining days between the current day (now) and a future date set as a date field in {{ inschrijven.datumEvenement }} globals {{ inschrijven.datumEvenement.diff(now).format('%...
6
votes
2answers
1k views

How can I display a "pending" entry in my "_entry" template?

I have an event site with dates in the future and past. I know how to display future entries as a listing: {% set entries = craft.entries.section('mySection').status('pending') %} But how do you ...
5
votes
2answers
1k views

How to retrieve entries from two entry-types ordered by different date-fields?

I have two entry-types, 'Events' and 'Reports'. 'Events' have a matrix-field ('eventMultiDate') that allows authors to assign multiple dates to an event (recurring). 'Reports' have the default '...
7
votes
1answer
436 views

How Do I show advanced Date filters for Events?

I am trying to setup an events section similar to that of Yelp's Events. They have a listing of all the upcoming events and have filters on the side for "Today, Tomorrow" etc... I received help from ...
4
votes
1answer
586 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
977 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
3answers
1k views

Display Entries in a calendar

I have a section for holding calendar entries stored by postDate in the CMS. On the front end I want to basically display these in a calendar. I have code which displays the calendar looping through ...
10
votes
1answer
6k views

Advanced query/filter based on date and values

I have a channel of events with a field ‘eventDate’ for the date/time of the event. Within that there are ‘types’ of events ‘eventType’. What would be the most efficient way of outputting the NEXT (...
8
votes
2answers
3k views

Multilingual Dates where date format varies

I have a multilingual site, and I want my dates formatted like: English site: July 13, 2014 Italian site: 13 lulgio 2014 So the month name is translated, and the order of the elements changes as ...
17
votes
1answer
1k views

How to show events for "This Weekend, Next Week"

Stemming from this original post I was able to show Events using a custom date field and successfully got "Today" and "Tomorrow" events to show up. How would I go about doing some custom Math to show ...
8
votes
1answer
2k views

Get Age from Date of Birth

I have an entry with a dateOfBirth Date/Time Field. Is it possible to calculate the current age from that field? I can't find a craft/twig function/filter to calculate the difference between 2 dates....
2
votes
1answer
692 views

Return entries with startDate or endDate within a calendar year

I have two date fields in my entry and I want to return those entries with either a start date OR and end date within a calendar year. I can get those with a startDate within the calendar year using: ...
3
votes
2answers
1k views

How can I group entries based on a dateTime field?

I am getting all entries from a section like this: // get the parent entry. {% set author = craft.entries.section('mySection').authorId(currentUser.id).first() %} // get the child entries from the ...
2
votes
1answer
720 views

Fetch all entries with dateUpdated after a given time

I'm trying to grab all Entries that were updated after a given date and time. It seems like I can grab all entries updated after a date using the following: {% set timeLimit = now | date_modify("-2 ...
2
votes
1answer
1k views

Output DateTime in that timezone related to the current locale?

Is there a way to loop through a day in 15-minute intervals, with the output of said intervals being localizable? This (cringe-worthy) snippet should help explain what I'm trying to accomplish: <...
1
vote
1answer
179 views

Paginate by Group

I am trying to group entries based on week and then paginate them the same way. I'm not quite sure how to go about setting each page to be a separate week/group though. Thoughts?
3
votes
1answer
1k views

How do you format a date for saving with users/saveUser on the front end?

Currently using a date picker to select a date and submit it on user registration, formatted as m/d/Y, have played with various formats but can't one that works. Any ideas?
2
votes
1answer
1k views

Set site locale to display correct date format in date/time field

The date field is displaying dates in US format (mm/dd/yyyy) but I need the UK (dd/mm/yyyy) format. According to the docs: Dates and times are both formatted for the user’s preferred locale. They ...
2
votes
1answer
1k views

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

Am using the Pikaday datepicker to add a Date field to the front-end of a Craft site: https://github.com/dbushell/Pikaday This is for integration with the Formerly add-on and the date is set to ...
2
votes
1answer
1k 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
218 views

Repopulate dateTime field in plugin settings page

In my plugin settings page, I have a startDate input which is a dateTime field. _settings.html {{ forms.dateField({ 'label': 'Start Date'|t, 'instructions': 'Choose a date'|t, 'id'...
1
vote
1answer
1k views

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

I am working on a plugin that has a date picker only (no time). I am attempting to set the postDate to the value of whatever date was chosen on the front-end. I realize I need to save in this format: ...
1
vote
1answer
2k views

How do I format the date and time I got from an entry?

I am working on a project where the content manager can add events (entries). These events have a date, starting time and end time. The fields in the cms show the option for adding a date, time and ...