Custom Module Search Date/Time adjust for Time Zone

I am using a Custom Module search using Min and Max on a custom datetime-local item and it returns incorrect results because search is UTC not local time CST.

How do I adjust the search -6:00 for Central Standard Time?

This is the Search Form parameters I am using with my custom property.
`<input type=“datetime-local” name=“prop_GameDate_Min” value="{{request.request_url.params.prop_GameDate_Min | date: “%Y-%m-%dT%H:%M”}}" >

<input type=“datetime-local” name=“prop_GameDate_Max” value="{{request.request_url.params.prop_GameDate_Max | date: “%Y-%m-%dT%H:%M”}}" >`

Can you not just save your module items with CST times?

Failing that, I guess you’d need dummy date entry fields that, on blur or just before submit, you’d convert the dates to javascript time objects, do the plus 6hrs math and populate the real hidden fields with the UTC times, then submit.

Then do the reverse on the results page if you need to show the search queries used.

Here’s a link which may help you get started:

@Adam.Wilson

Can you not just save your module items with CST times?

The time we enter would be CST. If I enter a date and time for the module Release date and/or Expiry date it is considered the local time, correct? It displays correctly based on the time entered and there is no 6 hour difference.

The custom module Date Min Max Search field doesn’t work on Release Date, or Expiry Date. The Search Module is alway using UTC so it is 6 hours off in my case. It sound to me like this is a bug. If not that means I have to make adjustments to any modules I need to filter by Date and/or time.

Thanks for reporting this issue, we will fix it in version 5.9.2

@Anastasia, That’s great I will be looking for it. Thanks!

@Anastasia am I correct in thinking that the module search currently works only on the date portion of the datetime string (ie: searching based on a min/max time isn’t possible).
If time portion IS NOT part of the search function, is that going to be included in the 5.6.2 fix as well, or should we submit a backlog request?
If time portion IS part of the search capabilities, what is the syntax/datetime format for doing this?

Hi @Adam.Wilson
Module search does work on the time portion. But it adjusts the timezone incorrectly.
So if you have timezone -6. Time in the admin is 7:10AM then searching by MIN date would be correct if you paste 1:09AM (item will be shown) and 1:11AM (item will disappear).
This is the bug that will be fixed in the patch.

1 Like

@Adam.Wilson maybe this will help you. I put a test together so I could figure it out and show the issue.

Here is a test page showing the issue.
https://gifr.trialsite.co/test

Here is the same test page on a site that has the bug fixed.
https://pearsite.trialsite.co/test

Time IS always part of the search no matter what syntax you use. date or datetime time always defaults to 00:00 on the min and the max. This is why you can put a min and max of the same date. You have to put a start time and end time.

Thanks @Rhatch that’s very helpful.
In your first test page (where the bug exists), is the search form at the every bottom still working. I just get all items returned regardless of date/time entered.

Anyway, great that there’s a fix on the way soon, so all good :slight_smile:

I copied it over so the module ID was wrong. It works now… or rather is shows it doesn’t work now…

1 Like

I believe it has been fixed with 5.9.2 as @Anastasia mentioned.

Yes, Works perfectly.