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.