How to switch the timezone of DateTime from UTC to other when using the date range filter

How to switch the timezone of DateTime from UTC to other when using the date range filter

zhhm946zhhm946 Posts: 2Questions: 1Answers: 0

Hi All,
I am new to frontend and Datatable. When I tried to use date range filter, the timezone of datetime shown in the calender is UTC, and I wanted that datetime to show in EST. Below are the figures, I have the datetime range work on the third column.
As you can see, when datetime range started by 05:05, there are two entries displayed, which arrival time is 00:05 by EST and 05:05 by UTC. And when datetime range started by 05:06, two entries are no longer displayed. Can anyone tell me how to have date filter show the time in EST, instead of UTC?

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • zhhm946zhhm946 Posts: 2Questions: 1Answers: 0

    Hi, colin

    Thanks for your reply!

    I have created a test case. And there is only one data since the probllem was basically about the date. live.datatables.net/nisukiyo/1/
    Please click on the calender. When the min date is 2022/01/24 00:02 or 2022/01/24 05:02, the data is still there. However, when the min date is 2022/01/24 05:03, the data is gone. But actually, the data should have gone when min date is 2022/01/24 05:02.

    I think the problem here is because of the timezone, and I just could not figure out how to correct that. Can you help me with that?

    Thanks for your time and support!

    Best,
    Hongming

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Hi Hongming,

    I think it is two different things giving you the problem here:

    1. The seconds - input value doesn't have a seconds parameter, so the input is just being set to the seconds at the time of creation. The value from the table also needs seconds to be set - which I've updated in the example here: http://live.datatables.net/nisukiyo/2/edit .
    2. It sounds like you don't want a less than or equal to comparison, but rather just a less than one. Changing the <= to < in the if condition will do that for you.

    Allan

Sign In or Register to comment.