KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Range Today Not Showing Data #2667

Closed Issac Rosa opened this topic on on May 11 - 5 comments

Issac Rosa commented on May 11

I have a widget that has the standard ranges - Today, Yesterday, This Week, etc...

I have 7 rows of data in my table with today's date - 2202-05-10. When I run select now() in my db, I get the current date and time - 2022-05010 22:42:22.

When the widget loads, and I select the Today range, the metric doesn't show the value but if I select Yesterday, the metric does show the correct value.

How do I make sure that the Today range is set to the correct timezone or locale?

KoolReport commented on May 12

The range from DateRange widget is always following the client timezone. There is the difference between the timezone of server and timezone of client. So we need to get the timezone difference between this two. This is how: we will create an hidden textbox and a javascript to fill the timezone of client. When user hit submit the daterange, the timezone difference will be submitted as well. At server-side, we will base on the time of server, timezone of server and timezone of client to determine the user-selected time range (in server timezone).

<form method="post">

    <input type="hidden" id="clientTimeZoneOffset" name="clientTimeZoneOffset" />
        $("#clientTimeZoneOffset") = new Date(). getTimezoneOffset();
    <button type="submit">Submit</button>

At server-side, you can get the clientTimeZoneOffset from $_POST["clientTimeZoneOffset"], you use it to calculate correctly the selected time range from user.

Hope that helps.

KoolReport commented on May 12

Oh, do you use the Dashboard Framework? My above code is for normal report.

Issac Rosa commented on May 12

Yes, I am using the Dashboard Framework. Also, I am in the Eastern time zone. The result from the database for Now() shows the correct time but at night, the Today range changes to the next day which is why I'm thinking there is a time zone setting or offset for the Dashboard.

KoolReport commented 6 days ago

I am really sorry for the late reply. I answered you and guessed the issue was timezone difference between client browser and server but still not sure so I have consulted dev.team. They said that the Today selected date is actually your web server date, not client. So there is left is the different of timezone between your database server and web server. Is your database timezone different from your web server.

You have use select now() to know the time of database server. Let try to use PHP with the code


echo date("Y-m-d H:i:s");

Let see if there is difference between them.

Issac Rosa commented 6 days ago

Got it. Thanks for pointing me in the right direction. I set the web server php_value date.timezone in .htaccess file and it shows the correct time.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed