Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(api): ensure we get correct date format

Carl-Gerhard Lindesvärd39775142e20a
diff --git a/packages/db/src/services/organization.service.ts b/packages/db/src/services/organization.service.ts
index 71517fcbb..bc4a582b7 100644
--- a/packages/db/src/services/organization.service.ts
+++ b/packages/db/src/services/organization.service.ts
@@ -1,3 +1,4 @@
+import { DateTime } from '@openpanel/common';
import { cacheable } from '@openpanel/redis';
import { escape } from 'sqlstring';
import { chQuery, formatClickhouseDate } from '../clickhouse/client';
@@ -249,7 +250,9 @@ export async function getOrganizationSubscriptionChartEndDate(
organization.subscriptionChartEndDate &&
new Date(endDate) > organization.subscriptionChartEndDate
) {
- return organization.subscriptionChartEndDate.toISOString();
+ return DateTime.fromJSDate(organization.subscriptionChartEndDate)
+ .setZone(organization.timezone || DEFAULT_TIMEZONE)
+ .toFormat('yyyy-MM-dd HH:mm:ss');
}
return endDate;