Timezone: Time showing in Calendar view and In from having 2:30 hrs difference

Hello All,

I created Custom app and custom doctype. I am displaying appointment details for custom doctype on Calendar. But the time on calendar and in doctype is different and having difference of 2:30 hrs.

Can anyone help me to solve this???

Maybe you have a timezone issue!

In demo.erpnext.com the Event EV00001 posted in the Calendar differs by 2 hours.

And Newfoundland here in Canada is 1/2 hour ahead of the mainland or UTC minus 3 1/2 hours https://en.wikipedia.org/wiki/Newfoundland_Time_Zone

A table here lists India as as UTC + 5:30 hours https://en.wikipedia.org/wiki/Time_zone

@clarkej I Written this query to display data in calendar is there any changes needed in following query

frappe.db.sql("""select c.name, c.docstatus as status, c.name as parent, CONCAT( c.doctor, "-",c.hospital, "-",c.surgeon) as doctor, addtime(c.appointment_date, c.appointment_time) as start_date, c.appointment_date as end_date from tabCase c, tabDoctor d where c.docstatus = 1 and c.doctor = d.name and (appointment_date between %(start)s and %(end)s)""".format(), { "start": start, "end": end }, as_dict=True, update={"allDay": 0},debug=1)

“In demo.erpnext.com the Event EV00001 posted in the Calendar differs by 2 hours.”

You don’t think best to resolve this first?

Yes I must research this but need a few days to dig into it - there is a fundamental learning to be had here!

@Bhagyashree_Aher my local instances do not have your time difference issue.

These ideas below may help solve your problem:

I have checked this issue.

Frappe is converting time to user time zone.

If system time zone if changes, then it will fix this issue.

Thank you kolate_sambhaji!

I have no clue how you ran your query or the context, please have you a pointer for the curious.

This turned up

 frappe@erpnext:~/frappe-bench$ find . -name *.py | xargs grep 'def now_datetime'
./apps/frappe/frappe/utils/data.py:def now_datetime():

but nothing for this

frappe@erpnext:~/frappe-bench$ find . -name *.py | xargs grep 'convert_to_system_tz'

And in the ‘bench console’ this worked:

In [15]: frappe.utils.data.now_datetime()
Out[15]: datetime.datetime(2017, 4, 29, 13, 19, 40, 27328)

In [16]: import frappe.datetime
ImportError                               Traceback (most recent call last)
/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.pyc in <module>()
----> 1 import frappe.datetime

ImportError: No module named datetime

Possibly a sql stored procedure but I am not savvy…



You can run this command in browser console, as it is javascript.

you can find convert_to_system_tz is used in calendar js.

Reference for browser console:


Excellent - I overlooked js and now will learn how to run it in a console - thanks for these!


I have done some more research.

While creating events frappe is not converting user time to system time zone, but while showing it in Event Calendar its converting time to User Time Zone.

So, if users are in different timezone, then it adds some trouble.

1 Like