0

I have very little knowledge of javascript. I'm calling an API on my band's website to display event dates that are entered into our band's scheduling system called Muzodo. However, even though the dates are displaying correctly within our system, the dates are showing up 1 day behind on our website (i.e. the event date is March 15, but our site is showing March 14). Is there a simple fix/something I can add to my existing code that will adjust the date by 1 day?

The site is hosted on Wordpress.

Here is what's in my header:

<script type="text/template" data-template="eventitem">
    <div class="muzodo_events">
        <table>
            <tr>
                <td class="col_one">
                    <p class="list-group-item-text date">${FormattedDate}</p>
                    <p class="list-group-item-text time">${TimeRange}</p>
                </td>
                <td class="col_two">
                    <p class="list-group-item-text name">${Name}</p>
                </td>
                <td class="col_three">
                    <p class="list-group-item-text address">${Address}</p>
                </td>
                <td class="col_four">
                    <a href="${CustomField_Link_Value}" target="_blank" class="x-btn">More Info</a>
                </td>
            </tr>
        </table>
    </div>
</script>

And here is what's in my footer:

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://muzodo.com/api/muzodoApi-v2.js?v=6"></script>
    <script type="text/javascript">
        var options = {
            exclude: "UNCONFIRMED",
            noEventsText: "Stay tuned for upcoming events.",
            template: "eventitem",
            dateFormat: "mmm d, yyyy",
            customFields: [
                {
                    field: "Link"
                }
            ]
        };
        
        getMuzodoEvents("46D54023-7AAD-1D49-8857-9461628569D5", "upcomingEventsDiv", options);
    </script>

Here is the date format script that it's pulling. I've searched through this thread, but I can't figure out which part of my script needs to be updated as none of them quite match the examples.

Thank you!

jennetcetera
  • 849
  • 1
  • 10
  • 18
  • This depends on the data being returned, but if it **always** returning a day before u can add one day to it with js – AdamTheFirst Mar 14 '22 at 06:25
  • Hi @AdamTheFirst – yes it is always displaying 1 day before. Do you know which JavaScript snippet would work for my scenario? I’ve tried a couple and can’t get them to work, however that’s no doubt due to my lack of knowledge as to where to put such a snippet and how to customize it for my situation. – jennetcetera Mar 14 '22 at 06:29
  • You should check how `FormattedDate` is being computed - perhaps there is a difference in the timezone ? – IVO GELOV Mar 14 '22 at 07:56
  • What is the format of the date in the API? How is it converted to a Date? How is the Date converted to a string? See [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results) – RobG Mar 14 '22 at 08:35
  • The Muzodo event calendar can be wired up to one of many calendar systems (it's own, Google's, Apple's) and expects you to provide a timezone param like `TZ=America/Chicago` to whatever calendar is specified. Your fix will likely be found there, rather than in your javascript. – phatfingers Mar 14 '22 at 11:18
  • Update: I've added the date API to the end of my question above (here https://muzodo.com/api/muzodoApi-v2.js?v=6). If I need to update that, I can't figure out which part of my script needs to be updated as none of them quite match the examples from this thread – https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results – jennetcetera Mar 14 '22 at 13:29

0 Answers0