Base solution for your next web application
Open Closed

tenant date time format #10502


User avatar
0
BobIngham created
aspnet zero 6.8.0, .net framework 4.6.0, .net core 2.2, angular

I am currently in the process of upgrading to the latest version but have a couple of jobs before it is released. Currently I have use this code to format some of my datetime strings: format: '{0:dd/MM/yyyy}' Given that culture is changed when a language is changed is there any way to find the the date format for the tenant or the current session in Angular? For example, when using Kendo grid I have to cast all dates back to javascript dates so I first grab the tenant timezone before doing so: let tenantTimezone = abp.timing.timeZoneInfo.iana.timeZoneId; Then I can carry out the following: if (d.deletionTime) { d.deletionTime = new Date(moment(d.deletionTime).tz(tenantTimezone).format()); } It's a pain but that's the way it is with Kendo... Is there any way I can grab the current date time format: let currentdateTimeFormat = ????? so I can format my dates accordingly: format: currentdateTimeFormat

I hope that makes sense, I wanted to ask this question now as work on upgrading is on-going and this useful information to know. Thanks in advance, Bob


2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi Bob,

    I couldn't find a way to get that format using Luxon but I thin you can convert your date to ISO using date.toISODate and then convert to to format Kendo requires.

  • User Avatar
    0
    BobIngham created

    Hi @ismcagdas,

    Thanks for the answer, I was looking to find the date format of the current tenant but I think you have pointed me in the correct direction:

    format: dt.setLocale(abp.localization.currentLanguage.name).toLocaleString(DateTime.DATETIME_SHORT);

    Closing this as this is ok for my needs.

    Cheers, Bob