Skip to main content

Questions tagged [datetime]

DateTime objects provide information about a given date/time.

Filter by
Sorted by
Tagged with
1 vote
1 answer
297 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 ...
T.Newton's user avatar
1 vote
1 answer
248 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....
carlcs's user avatar
  • 36.3k
1 vote
1 answer
417 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 ...
Damon's user avatar
  • 4,706
2 votes
1 answer
553 views

How do I convert a date stored in UTC to the user's current locale in PHP?

I have a date stored in the database in UTC. 2016-01-13 09:01:16 I can query the database and output this date just fine. But it outputs in the date in the wrong timezone. How do I adjust a date ...
Ben Parizek's user avatar
  • 13.5k
1 vote
2 answers
119 views

Start Matrix loop from item that contains todays day

I have a Matrix block weeklyMenuItems, each item in the block has a dropdown with days of the week (Monday, Tuesday etc). Each entry will have a Matrix block with 7 items, matching the 7 days of the ...
MikeeBee's user avatar
  • 155
1 vote
2 answers
128 views

Output two date languages on the same page without localization

I'm trying to output a date like this for instance: {{ now|date('l, j-m-Y') }} This outputs the date in my standard language. I need it output on the same page in English too. Is this possible?
noregt's user avatar
  • 1,062
1 vote
1 answer
532 views

How can I get the server's timezone in a Craft plugin?

I'm setting up cron jobs from my plugin and I need to format the date in the server's time zone. It looks like Craft is overriding the timezone set in php.ini because PHP's date_default_timezone_get() ...
Jameal G's user avatar
  • 266
0 votes
1 answer
407 views

Importing Unix timestamp into date time field

I have a Unix timestamp in my feed (1457685095000) and I am trying to map it to the date created entry field and I have another that I am trying to map to a time input field. The created date is ...
Willam Owen's user avatar
1 vote
1 answer
50 views

Escaping characters in entry.postDate|date

{{ entry.postDate|date('jS F Y \at ga') }}This should produce this 5th November 2016 at 4ambut it doesn't seem to recognise the escape and adds 30 instead of at.
Nutmeg's user avatar
  • 598
1 vote
1 answer
115 views

Entry not saving when date isn't changed using frontend form

When editing an entry (actually it's a product within Craft Commerce but everything seems the same) with a pre-existing date, the field looks like this: <input name="fields[date][date]" value="06/...
Clive Portman's user avatar
2 votes
1 answer
219 views

Date/Time field outputting time with additional minutes

I've having an issue where a Date/Time field (time only) is outputting the time in the front-end template with an extra 10 minutes. In my template I'm using entry.startTime|date("g:ma”). In the DB ...
Matt Ellis's user avatar
1 vote
1 answer
1k views

Comparing current date to multiple entry matrix date fields

I need to display an entry only if the date fields within its Matrix are current. So, only display if the startDate is greater than or equal to today and the endDate is less than or equal to today. ...
Chattervast's user avatar
2 votes
1 answer
303 views

List Only Available Times/Dates in Solspace Calendar

I have the following code that will output the UNAVAILABLE (previously booked) times of a Target Date. How would i edit this to output (in 30 minute increments) only the AVAILABLE times with Solspace ...
Christopher Healey's user avatar
1 vote
1 answer
96 views

Group by day does strange exeptions

I have a list of forms which I want to sort by day: {% set groupVerbund = 'datum.day' %} {% set allSubmissions = craft.amForms.submissions({ formHandle: 'reservation', limit: null}).find() %} {...
KSPR's user avatar
  • 3,786
3 votes
2 answers
2k 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 ...
Damon's user avatar
  • 4,706
3 votes
1 answer
215 views

How to query entries and take into account the timezone offset? - ChartHelper

I'm trying to query a range of entries and my results are not returning all the entries in the range I am trying to target. My situation relates to displaying data on a chart using the Craft ...
Ben Parizek's user avatar
  • 13.5k
3 votes
1 answer
1k views

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

I've got a generic newsletter template. Now some of our newsletters are in Spanish. It's overkill and more complicated for the admins to bother with settings up different locales, so instead I'd like ...
mijewe's user avatar
  • 336
9 votes
2 answers
6k views

Display entries if Field Date is past Now

I'm trying to make a upcoming and past event page. I can make an if statement for displaying the past or upcoming events but the problem is if I limit the amount of entries to be displayed I realised ...
Justin Dekkers's user avatar
1 vote
1 answer
143 views

Search for Matrix Block by Date in plugin

I am trying to search for specific matrix blocks by date like so: $criteria = craft()->elements->getCriteria(ElementType::MatrixBlock); $criteria->ownerId = $entry->id; $criteria->...
Aaron Berkowitz's user avatar
1 vote
2 answers
947 views

Validating Date of Birth format from a form field value

I'm working a on website project which includes a web form which asks for various personal details, one of the fields on the form is Date of Birth. The form is being validated by a custom plugin ...
James White's user avatar
  • 1,171
1 vote
1 answer
96 views

How do I sort and display event entries when each event can have multiple start times?

I have two different event types in my Events channel. The first one is events and it is very straightforward: Title, Description, Date. The other one is films and it is a little more complex: Title, ...
Greg Jenkins's user avatar
2 votes
0 answers
345 views

Setting a date range on entry parameters

I'm working on a site that uses a date slider to select members of the site by birthdate. I want to show the users by gender and between two "ages". For example: Male, between 40 and 50 years old. The ...
Jan's user avatar
  • 363
2 votes
1 answer
234 views

How do I check if an Entry is new?

How can I check if an Entry was posted less than a month ago?
darylknight's user avatar
  • 3,290
1 vote
1 answer
546 views

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

I've just noticed that there's a Date Created value that appears for each entry in the control panel. Here's a screenshot: . How can I edit this Date Created value? I've just looked at the ...
Stephen's user avatar
  • 685
2 votes
1 answer
72 views

Separate time settings from user locale?

I would like to render the DateTime fields in the backend with european time format, even though the user I'm logged in with is set to English/US. Is this possible?
Fred Carlsen's user avatar
  • 2,997
1 vote
2 answers
625 views

Format keys in Element API plugin

'criteria' => [ 'section' => 'news', 'date' => craft()->request->getPost('date') ], How to make that worked like this: 'criteria' => [ 'section' => 'news', 'date-...
Vitaliy  Badalov's user avatar
0 votes
2 answers
942 views

Criteria entries by date field

I want to get only entries with a specific date. I created a date field customDateField. It has the following code: {% set entries = craft.entries.section('orders').customDateField('2016-04-14') %} ...
Vitaliy  Badalov's user avatar
1 vote
1 answer
92 views

How can I build a combined search without making all fields required?

I'm trying to build a form where users can search for events based on a date range, location and price range. I've got the form working, but having a bit of trouble when some fields/ selects are left ...
molmol's user avatar
  • 13
1 vote
0 answers
94 views

forms.timeField not respecting time zone

I have a plugin that uses a datetime variable to record a class start time. When I save the training record the time is changed from local MDT to GMT into the database, and when displayed again it is ...
Jim Evans's user avatar
1 vote
1 answer
286 views

Getting UTC DateTime from Model attributes

The AttributeType::DateTime in model attributes saves as UTC which is great, but upon getting that attribute I receive a Craft\DateTime object with my server timezone set for it, and thus the time ...
Gustavs's user avatar
  • 406
3 votes
2 answers
1k views

date_modify relative time

I'd like to reopen this question: The answer was a plugin called Nice Time But This plugin is depricated and the creator stats that this functionality is acheivable via the date_modify filter. Yes ...
KSPR's user avatar
  • 3,786
1 vote
1 answer
571 views

Displaying entires by year from a custom date field

I have a date field (date) in my entry and I wish to get all entries of a specified year. Can’t figure it out at all. Here’s what I have now, to sort them by that field: craft.entries.section('...
Eric Chantigny's user avatar
3 votes
1 answer
490 views

Is it possible to modify the input format for dates in front end form?

From other threads and my own tests a date field needs to be input in the format of 10/15/2012 (mm/dd/yyyy). But that's not very "British", is there any way to modify it?
Paul Frost's user avatar
  • 1,060
1 vote
3 answers
2k views

Create date/time from string via form

I'm using the wonderful A&M form plugin to create a form on my site, and I have 3 dropdowns for the user's birthday: month, day, and year. Currently, I have it set up so that when the form ...
Ryan's user avatar
  • 1,952
2 votes
1 answer
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 ...
Cole Henley's user avatar
  • 1,741
2 votes
3 answers
1k views

Escape characters in format

I'm trying to find a method of escaping characters in Craft's DateTime object. This is the output I'm trying to achieve: 16th January 2016 This is what I've tried: {{ article.postDate.format('j\<\...
William Isted's user avatar
2 votes
1 answer
1k views

If date is between conditional

I want to check if it's winter. What is the best way to write a "between dates" conditional? {% set saison = now|date('m-d') %} {% if saison (saison >= '11-22' and saison <= '03-21') %} Jep ...
KSPR's user avatar
  • 3,786
0 votes
2 answers
419 views

Showing pagination for a date range of entries

Pulling hair out here so looking for divine inspiration. Trying to list a set of events/entries grouped by day. This is fine when all the dates are organised by an event date but when we introduce a ...
Cole Henley's user avatar
  • 1,741
1 vote
1 answer
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: ...
Damon's user avatar
  • 4,706
3 votes
2 answers
225 views

Show events until Midnight

I have a list of events which should list each event until midnight of said day. So If a gig happens at 17:00 it should still be visible until midnight of the same day. I came relatively close (I ...
KSPR's user avatar
  • 3,786
5 votes
2 answers
6k views

Get current date / time in specific timezone?

How can I get the current date / time for specific timezones? My local time is easy: {{ now|date("H:i") }} So how can I get this for New York? or Singapore?
Johannes Lamers's user avatar
1 vote
1 answer
913 views

How do I use URL parameters to filter a channel by a date field?

How do I filter entries by URL parameters. The url is /booking?month=november&year=2015. So far I have: {% set allEntries = craft.entries.section('availability').order('availabilityStartDate')....
user1070143's user avatar
  • 1,106
2 votes
2 answers
1k views

Date picker field type - quickly select year?

I need a "date of birth" field. Out of the box, the date picker only allows moving left/right by month, which doesn't work for selecting years. Is there a way to configure the date picker that Craft ...
Jure Srpcic's user avatar
1 vote
1 answer
1k views

The timezone could not be found in the database

This one is new to me. I've got the timezone set in my admin panel to Denver but I get this this error when I try using a global in my template... DateTime::__construct(): Failed to parse time string ...
brunam's user avatar
  • 391
0 votes
1 answer
1k views

How to compare just the date part of a dateTime field?

Ok I want to list event entries based on the start date of those events. I have a route set up which provides the date in the same format as held in the start date field. But trying to compare this ...
Lettie's user avatar
  • 2,033
1 vote
4 answers
3k views

How to properly format this date

I have events that are presented by month. Right now they are being separated by Month but the heading for each chunk shows January as the month for each one. Not sure why, or how to fix it, am ...
Rockwell Rice's user avatar
2 votes
2 answers
229 views

Date conversion returning December for every single digit month representation

I can't figure out what I'm doing wrong, but trying to convert single digit months to their name representations (ex. '4' to 'April' in English) but am just getting December printed out for every ...
user avatar
0 votes
1 answer
149 views

Date changing algorithm

Im working on a school website where the client would like a global date that is the start and finish of all the classes. This part is easy as I have made a Global where you enter the Start and End ...
JeffTalbot's user avatar
11 votes
1 answer
7k 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 (...
Christopher Healey's user avatar
2 votes
1 answer
3k views

How to calculate the number of hours left?

This question relates to my previous question on stackexchange about the difference in days between 2 dates. This ended up being the working solution: {{ date( inschrijven.datumEvenement|date ).diff( ...
Robbie Post's user avatar