Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [datetime]

DateTime objects provide information about a given date/time.

0
votes
0answers
44 views

Object of class DateTime could not be converted to string

I am seeing the following error when I try to submit a front-end entry form, but I cannot find the cause. Object of class DateTime could not be converted to string Below is the error result from ...
0
votes
2answers
22 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
30 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
26 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
25 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
20 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
48 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|...
0
votes
0answers
35 views

Handeling date in active record and craft

Is there any better way to do this. $now = DateTimeHelper::currentUTCDateTime(); $last = new \DateTime($viewCount->dateUpdated, new \DateTimeZone('UTC')); $last_check = $now->getTimestamp() - $...
2
votes
1answer
75 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
216 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
187 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
28 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. {% ...
0
votes
1answer
53 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
134 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
72 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
276 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
58 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
232 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 ...
3
votes
1answer
96 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
713 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
23 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
113 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
45 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
27 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? ...
1
vote
0answers
56 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
49 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
93 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 ...
3
votes
1answer
128 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 ...
1
vote
1answer
108 views

Displaying variable in array in array = Impossible to access an attribute (“date”) on a string variable (“”)

I'm trying to display a saved date from a json file. I currently have: {% set batchRowStats = craft.analytics.loadSavedBatch() %} {% for stat in batchRowStats %} <tr> <td>{{ ...
1
vote
1answer
141 views

Date value different in CP and database

Have a site registering users. The user record in the CP says they registered at 11:39 June 12. The database 'dateCreated' says 10:39. The site settings timezone are UTC+1 BST. PHP config date....
0
votes
0answers
96 views

Expire field if last date in array is less than current date

I currently have a lightswitch which when turned on, enables me to input a list of dates which I would like to expire once they've passed the current date and once all dates have expired, turn off the ...
3
votes
1answer
62 views

How can I get entries where a date is within a dynamic date range?

{% set params = { section : 'events', order : 'eventStartDate asc', eventStartDate : '>=' ~ now, limit : row.itemsPerPage.value } %} I am trying to pull a set of event ...
3
votes
1answer
81 views

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

How can I check if today is the second or last sunday of this month? My effort: {% set now = now|date('U') %} {% set monthyear = now|date('F Y') %} {% set secondSunday = now|date_modify("#{monthyear} ...
1
vote
1answer
136 views

How can I correctly set the time of a dateTime field from a front-end form?

I am using jQuery-timepicker to give the user an option to pick a starting time and ending time. My init looks like this: $('.timepicker').timepicker({ scrollDefault: 'now' }); When I save the ...
3
votes
1answer
49 views

date in database -1 day as on frond-end

We just found out that in the database birthday field, all dates has 1-day difference than what is shown on the front-end. On the front-end, it is the correct date by the way. Question: Is it a bug ...
1
vote
1answer
77 views

Store Hours: show current open/closed state

I'm wanting to do two things with this great plugin, but am having a bit of a mind-melt... 1) I'd like to show the current state; e.g. Closing soon; Open now; Closed; Opening Soon 2) I'd like to ...
3
votes
1answer
271 views

Entry view count in the last 24 hours

I'm working on a typical craft blog with articles. I know there is a plugin that was used to teach craft plugin development that tracks entry visit counts here: https://straightupcraft.com/craft-...
4
votes
1answer
51 views

Is it possible to create event with multiple date/time (out of box)

I have an event that runs from Monday to Sunday from 9am to 6am but on Thursday the time is from 9m to 8pm. How can I add repeat dates with diffrent time for Thursday?
1
vote
0answers
66 views

How to create an archive dropdown menu

How do I create a dropdown menu that filters all the posts into month and year, and then link to a template that has the entries of that month and year displayed? This is as far as I've gotten: <...
1
vote
1answer
52 views

iCal feed import - Timezone query

Has anyone got any experience working with iCal feeds - I have written a plugin utilising the CalFileParser library but the UK clock changes have thrown all the items out, so eg an all day event is ...
2
votes
1answer
137 views

Get future multi-day event entries with custom date field

I have an event section with custom fields for eventDate and eventEndDate. I'm listing upcoming events in my template using: {% for event in craft.entries.section('events').eventDate('>='~now)....
3
votes
1answer
145 views

Display X minute / hours / days in entries

I am trying to print if statement for x time or x day ago for each published entries. For example the entry is posted x minutes ago should display x minutes ago or x hours ago. Same for days and ...
1
vote
0answers
45 views

DateTime is null in Live Preview

I made a custom field type (two datetime fields for starting / ending time). They have the good value when I loop in value in an entry, but have null value in Live Preview. Do you have an idea of what ...
1
vote
1answer
62 views

Using data within a mixed attribute type to query Craft entries dates

I wish to have a custom fieldtype which contains the standard datetime field abilities along with storing an extra piece of data. I have created a custom fieldtype for this with a mixed attributetype ...
2
votes
2answers
150 views

Trouble getting entries after a certain date

I have a bunch of entries with field eventStartDate and eventEndDate. First I set the date {% set fwd = entry.eventStartDate|date_modify('+30 min')|date('c') %} When I output the value of fwd, ...
2
votes
3answers
306 views

Making Craft\DateTime Object from string in Twig

I'm trying to use Craft's native datepicker with a plugin I've made for the admin section. I've got some code that works; {% from "_includes/forms" import date %} <h3>Start Date</h3> {...
1
vote
1answer
72 views

How to display entries relevent to date assigned

I am creating a website for not-for-profit organization that help victum of domestic violence. I have a page called Event which display all fund raising events under each month. I have setup Date/...
1
vote
1answer
92 views

Group entries by category than by month based on Date/Time field

I would like group entries first by what category they are in, than group by month based on a Date/Time field like this for example: Category 1 February 2017 Event 1 March 2017 Event 4 (in all ...
1
vote
1answer
173 views

Archive pages with full month names?

I've got News Archive pages that display all entries posted in a certain month/year. For example June 2016 shows all entries created in June of 2016! I'm fetching the entries based on craft.request....
1
vote
1answer
239 views

How can I convert a date format from my plugin so it saves correctly?

I have a plugin that includes a datepicker. I initialize the datepicker like this javascript $('.datepicker').datepicker({ 'format': 'mm/dd/yyyy', 'todayHighlight': true }); I am saving ...