Fullcalendar time correction with Ajax and Flask: Step-by-step guide

After creating an appointment on the calendar, the start and end time display correctly. However, upon reloading the page, the datetime appears different on both the calendar and in the database.

For instance, if I schedule an appointment from 09:00 AM to 10:30 AM, the data stored in the database shows:

Start: 2017-04-30 15:00:00

End: 2017-04-30 16:30:00

In my view.py:

appointment = Appointment()
appointment.start_time = parse_appoitment(start)
appointment.end_time = parse_appoitment(end)
appointment.note = data
appointment.user_id = abonent.id
appointment.client_id = client.id
db.session.add(appointment)
db.session.commit()

Also, here is the date parser:

def parse_appoitment(time):
    start_datime = str(time)[0:25]
    date = parse(start_datime)
    return date.strftime('%Y-%m-%d %H:%M:%S')

The javascript code is as follows:

{% if client.is_subscriber(master.id) %}
  $(document).ready(function() {

    var initialLocaleCode = 'ru';
    var d = new Date();
    var strDate = d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate();

      $('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay,listMonth'
      },
      defaultDate: moment(),
      defaultView: 'agendaWeek',
      height: 650,
      locale: initialLocaleCode,
      local: 'GMT+06:00',  
      
      // The rest of the JavaScript code goes here
      
    });
{% endif %}

I am unsure if adding local: 'GMT+06:00' has any impact as I always encounter the same issue every time.

Edit:

I neglected to mention the format received after submitting an appointment and before parsing it:

Sun Apr 23 2017 15:30:00 GMT+0600 (+06)
to
Sun Apr 23 2017 17:00:00 GMT+0600 (+06)

Despite scheduling from 09:30 to 11:00, I still receive the aforementioned result.

Answer №1

To ensure proper functionality, remember to adjust the timezone settings to 'local' in your configuration:

timezone: 'local'

With this adjustment, everything should be working smoothly!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Updating Content in HTML Code Generated by JavaScript

My goal is to change the innerHTML of a div when it's clicked. I have an array of dynamically generated divs, and I want to target the specific table that the user clicks on. I attempted to set the IDs of the tables dynamically in my JavaScript code: ...

Creating a visually appealing gantt chart in React Native using the react-google-charts library - here's how!

These are the current packages I am using: react-google-charts 1.5.5 react 16.0.0-beta.5 react-native https://github.com/expo/react-native/archive/sdk-22.0.1.tar.gz I am currently working on rendering a Gantt Chart and you can find an example here and a ...

Error event triggered by Ajax call despite receiving 200 ok response

$.ajax({ url: 'http://intern-dev01:50231/api/language', type: 'GET', dataType: 'json', success: function() { console.log('Success! The call is functioning.'); }, ...

What is the best way to extract user input and pass it to an AJAX request URL?

Recently, I successfully completed an AJAX request using AngularJS. You can check out the code here. Everything was working perfectly until I tried to add a dynamic variable (city) to the link like this: $http.get('http://api.wunderground.com/api/KEY ...

Tumblr jQuery Like (utilizing rel attribute for selection)

I developed a custom HTML5 theme using masonry and infinite-scroll, which has been functioning well. I am now trying to add reblog and like buttons to each post but I'm facing an issue with the like button not working. Here is the URL to the theme: ...

What is the method to determine the size of an array of objects where each object contains its own internal array?

Here is the data that I have: var a=[ { name: "time", Details:[ {value:"month",checked:true,id:1} ] }, { name: "product", Details:[ {value: ...

Sending AJAX information to multiple pages

I have created an HTML page where I am struggling to pass two variables using the POST method to a PHP page. The PHP page is supposed to accept these variables and then call an API to retrieve data based on them. However, my challenge is in receiving this ...

One way to incorporate type annotations into your onChange and onClick functions in TypeScript when working with React is by specifying the expected

Recently, I created a component type Properties = { label: string, autoFocus: boolean, onClick: (e: React.ClickEvent<HTMLInputElement>) => void, onChange: (e: React.ChangeEvent<HTMLInputElement>) => void } const InputField = ({ h ...

Bringing the Jquery cursor into focus following the addition of an emoji

Looking to add emojis in a contenteditable div but facing an issue with the cursor placement. Here is a DEMO created on codepen.io. The demo includes a tree emoji example where clicking on the emoji adds it to the #text contenteditable div. However, after ...

Unable to navigate using single-page navigation due to JavaScript malfunction

I'm struggling with this particular code and I'm hoping for some assistance. My experience with javascript is limited, so I'm reaching out for help instead. I am trying to implement the jquery single.page.nav feature that enables navigation ...

Why am I encountering http://localhost:3000/api/auth/error?error=AccessDenied when implementing Google signin in my Next.js application?

Can someone please assist me in resolving an issue I am facing with my NextJs application using Google signin? Whenever I try to sign in, I get the error message "http://localhost:3000/api/auth/error?error=AccessDenied". Why is this happening? Here is a ...

The application of textures is not being done correctly

Trying to incorporate two textures - one for the wall and another for the floor. However, after rendering, only a solid color is displayed instead of the desired texture. Below is the configuration of my scene and camera: const tempScene = new THREE.Sc ...

Error encountered while attempting to import external JSON data into SurveyJS

This Codepen example showcases SurveyJS using a simple JSON structure: var json = { "questions": [{ "type": "text", "title": "Test question 1", "name": "Test question" }, { "type": "comme ...

What is the process for subscribing to setInterval() in an Angular application?

I'm currently working on developing an iOS location tracking application using the Ionic 5 Framework, Angular, and the Cordova Geolocation Plugin. In the past, I was able to track user location changes using the watchPosition() function, which worked ...

Encountering an error while trying to run a Next.js application on Linux Mint

View the error screenshot After creating a new Next.js app with npx create-next-app, I ran npm run dev and encountered the following error message ...

The table loaded with Jquery/AJAX is not appearing on Internet Explorer 9

I'm encountering an issue with a table loaded via Jquery/AJAX. function initializeDaily() { jQuery.post( 'ajax-functions.php', { 'action':'getdailyStatus' }, function(respons ...

Creating a JavaScript function that responds to multiple click events

Can someone please help me out? I have the link to the output of my work below using JavaScript and HTML: My goal is for only one circle to be active when clicked, while the others are disabled. Currently, when I click on a circle and then another one, bo ...

Incapable of stopping a form submission when a certain criteria is satisfied

I am currently working on a form validation system using jQuery $.ajax. The aim is to only allow submission of the form if a specific condition, data == 1, is met. var preventSubmit = function() { return false; var form = $(this), name = form.find ...

Choosing read-only text fields using JQuery

I am working on an ASP.NET MVC project and I am looking to select all text boxes with the "readOnly" attribute on the current page. Once identified, I want to trigger a modal jQuery dialog on keypress for each of these disabled text boxes. Any suggestion ...

Exploring the versatility of HTTP actions in Express: Using GET and

Currently, I am setting up a server through express. While everything is running smoothly with my project, I have a small query that is not related to the project itself. My confusion lies in the requirement to use the GET method when, in my opinion, usi ...