Posted: November 7, 2017 at 7:57 am
|
Hi Old system used this SQL
Does anyone have an example of displaying a date range like this in a table…. and ideally would be great for admins to have an override at the top such as a drop down that said show: last 7 days, last 14 days, last month. We are using Chronoforms plugin to build our own frontend admin area to display these adminpages so its not in the WP dashboard. thanks |
Hi there, The EE4 developer documentation for Model querying shows some examples and explains how to use the model system to query Datetime fields instead of writing direct db queries: |
|
|
Thanks Josh Ill take a look in the morning and let you know how I get on π |
|
Hi Josh Well I think I spent several hours today reading those great docs on EE Models and Date times etc. I have a simple query now working and displaying events but the timezone is all wrong. Its fine on the main site on the upcoming events widgets, shortcodes but not in my test code. I am in UK so GMT timezone. My server is in Chicago and I have WordPress set to America/Chicago timezone. So I just created an event to start at 08:00 am. In the SQL table it is stored as 2017-11-25 14:00:00. Chicago is 6 hours behind GMT so I guess as per the docs worpdress stores the date as GMT time. In my code i’m doing this to simply show events between two dates….
It’s working but the SQL date times don;t match what I’m asking, notice here the SQL outputs a time of 06:01:00 when I used 00:01 in my code. so again this is out by 6 hours the wrong way so looks like its showing that time in GMT?
and when the events are displayed they show timezone in use is correct America/Chicago but the time of the event instead of 08:00am shows as 02:00am? I could understand if it showed 14:00 as per the SQL table GMT time but this is showing 6 hours the wrong way.
Please help me to realise what I;m doing wrong in terms of timezones here π Thank you so much Jonathan |
Hi Jonathan, Since Event Espresso support staff are not developers, it’d be best to open an issue on Github, then put a Question label on the issue. One of the developers can follow up with your coding-related question. |
|
|
Hi Josh Ahh I’ve seen all the great code snippets you’ve put out there…..so am pretty sure you know your stuff π I’m not trying anything complicated here just to display some events between two start dates using the code supplied in your plugin docs. My query is do you have any idea why when I submit a query with this date time DbSafeDateTime(‘2017-12-19 00:01 the actual SQL generated by EE is showing a different time of 6 hours difference? Datetime.DTT_EVT_start < ‘2017-12-19 06:01:00’ it must be a simple timezone issue so am i missing something form the few lines of code above to get this in to the correct timezone? Thanks…. if you can’t hep on this simple query I’ll have to post on github. Jonathan |
|
Hi Josh….. all sorted! It was the chronoforms plugin that was affecting the times. I found this line of code and have now commented it out in the plugin and all working as expected now.
Took me almost two days to work that one out – sigh! π thanks |
You could share this information with the plugin author of the chronoforms plugin, and maybe they’ll include a better way to get the current time in their plugin: https://weston.ruter.net/2013/04/02/do-not-change-the-default-timezone-from-utc-in-wordpress/ |
|
The support post ‘Show Events within certain date range’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.